Why http client Post with payload using longchar fails while character works - Forum - OpenEdge Development - Progress Community

Why http client Post with payload using longchar fails while character works

 Forum

Why http client Post with payload using longchar fails while character works

This question is answered

I was struggling for a couple hours with a http client post request.  I kept getting a 400 (Bad Request) error.  Once I switch the payload to be a character instead of a longchar it worked even though the values where the same.  Is this expected behavior?   

Thanks in advance,

Rod

11.6 Linux

// oRequestBody = NEW STRING(lcSstorePayload). //fails

cSstorePayload = lcSstorePayload.

oRequestBody = NEW STRING(cSstorePayload). //works

oRequest = RequestBuilder:Post(links.uri, oRequestBody)
:UsingBasicAuthentication(oCreds)
:ContentType('application/json')
:AcceptJson()
:Request.

Verified Answer
  • For JSON, you should

       fix-codepage(lcVar) = "UTF-8"

    since JSON is spec'ed / defined as UTF-8.

All Replies
  • What happens if you use the longchar but after defining it you add the following line of code before using it:
     
    fix-codepage(lcVar) = session:cpinternal.

  • Rod,

    That's not expected.

    What exact version/service pack?

    It'd be interesting to see what the request looks like. You can dump it into the session temp-dir when you bump the log-manager's logging level. Add the code below to your test .P and you'll get a request-raw.txt in the temp-dir. That may hold some clues. You can/should also contact tech support.

    log-manager:logfile-name = session:temp-dir + '/mylog.log'.

    log-manager:logging-level = 5.

    log-manager:clear-log().

  • For JSON, you should

       fix-codepage(lcVar) = "UTF-8"

    since JSON is spec'ed / defined as UTF-8.