I have a request from the devs I'm working with on this endpoint of theirs. They have asked me if I can add a charset to the application/json header. As best I can tell, there doesn't seem to be a way to do that? Basically I hit this code in wwhttp.httpgetex:
IF llHasPostData
DO CASE
*** Explicit content type overrides manual content type
CASE !EMPTY(this.cContentType)
tcHeaders = "Content-Type: " + this.cContentType + CRLF + tcHeaders
this.cContentType is "application/json". How do I get "; charset=UTF-8" to be appended to that? I tried setting lDecodeUTF8 to .t. in my http object but the class seems to create its own local instance and I'm not sure that gets passed through or if it's even relevant?
So I read the fine documentation and it implies that I could explicitly set cContenType after instantiating my http object. However, HttpGetEx still seems to declare its own local object and my explicit setting of that property did not seem to carry thorugh.
This should do it:
loHttp.AppendHeader("Content-Type","application/json; charset=utf-8")
Or simply:
loHttp.cContentType = "application/json; charset=utf-8"
cContentType
should alwyas be applied as long as there is POST data to send and it will override the nHttpPostMode
property if that's set.
++ Rick ---
I'll try expclictly adding the header and let you know.
Thanks.
When I append the header, as opposed to setting cContentType, the final post object ends up with 2 ContentType headers. Is that valid?
I'm happy to record another debugging session if that's useful.