REST-call with two longchars

Posted by bart.syryn on 17-Sep-2019 06:40

Hi, I have a REST-service and the procedure needs to recieve two longchars. So INPUT PARAMETER lc1 AS LONGCHAR and INPUT PARAMETER lc2 AS LONGCHAR. But it gives me an error (internal server error 500 - postman). If I just use 1 longchar then that's ok. Is it possible to have two or more longchars as input parameter ? And if so, how can that be achieved ? Regards, Bart

Posted by marian.edu on 19-Sep-2019 05:08

Base64 encode is used for binary data but what will be the reason to encode a string?


Bart, you say your routine expects longchars - that you probably try to read in temp-tables - but in the payload those are objects not strings. You have two options, either change the service definition to have the parameters mapped to actual temp-tables or if you can't change the backend the data in the payload must be 'encoded' as string (JSON.stringify).
 
Marian Edu

Acorn IT 
www.acorn-it.com
www.akera.io
+40 740 036 212

All Replies

Posted by Mike Fechner on 17-Sep-2019 06:44

Mind sharing the payload you send, details about mapping in the REST resource and maybe an error message that comes with your 500 error (either returned to Postman or from the AppServer logfile)?

Posted by bart.syryn on 17-Sep-2019 06:55

Hi Mike,

What I send through Postman:

{

"request": {

"authToken": "aaabbbccc",

"dossierNr": 1,

"jsontttable1":

[

{

"srchfield": "naam1",

"srchstring": "abc"

}

],

"jsontttable2":

[

{

"srchfield": "naam2",

"srchstring": "def"

}

]

}

}

Nothing in the AppServer Log.

Error in Postman is '500 Internal Server error'.

I can't find anything in the Logs of Tomcat.

Bart

Posted by Torben on 18-Sep-2019 19:05

Longchars should normally be base64 encoded in the request body

{

"request": {

"Longchar1": BASE64ENCODED-VALUE,

"Longchar2": BASE64ENCODED-VALUE

}

}

Posted by marian.edu on 19-Sep-2019 05:08

Base64 encode is used for binary data but what will be the reason to encode a string?


Bart, you say your routine expects longchars - that you probably try to read in temp-tables - but in the payload those are objects not strings. You have two options, either change the service definition to have the parameters mapped to actual temp-tables or if you can't change the backend the data in the payload must be 'encoded' as string (JSON.stringify).
 
Marian Edu

Acorn IT 
www.acorn-it.com
www.akera.io
+40 740 036 212

Posted by Torben on 19-Sep-2019 06:38

It is years since we stopped working with the mapped/annotated rest and moved to WebHandler for REST

But when we did I remember we had to encode to get it to work!

Maybe because our longchars had json text,

Posted by bart.syryn on 19-Sep-2019 06:41

Thanks for all the suggestions !

I tryed encoding but that wasn't any luck. Finally I just builded a complete new procedure and War file, with encoding, and now it works. Why ? I really don't know. It looks like my War-file was corrupted or so … I have no idea. But now it works !

Thanks !

This thread is closed