Why http client Post with payload using longchar fails while

Posted by Rod Anderson on 10-Aug-2017 14:44

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.

Posted by Peter Judge on 10-Aug-2017 15:25

For JSON, you should

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

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

All Replies

Posted by Brian K. Maher on 10-Aug-2017 14:54

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.

Posted by Peter Judge on 10-Aug-2017 15:24

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().

Posted by Peter Judge on 10-Aug-2017 15:25

For JSON, you should

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

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

This thread is closed