REST-call with two longchars - Forum - OpenEdge Development - Progress Community
 Forum

REST-call with two longchars

This question is answered
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
Verified Answer
  • 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
  • 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)?

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • 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

  • Longchars should normally be base64 encoded in the request body

    {

    "request": {

    "Longchar1": BASE64ENCODED-VALUE,

    "Longchar2": BASE64ENCODED-VALUE

    }

    }

  • 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

  • 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,

  • 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 !