Sending a json POST request WITHOUT encoding to UTF-8?

I’m working with a client to set up some push notification stuff in their app. After going back and forth about why my network requests are creating bad requests on his server, we’ve found out that it’s due to the network request changing this:

Content-Type: application/json

 

to this:

 

Content-Type: application/json; charset=UTF-8

 

It’s the UTF-8 part that is causing problems, if we curl without it then the request works. Is there a way for me to disable this charset being added in network.request?

+1 exact same problem

Anyone have a fix I do not want Corona to append charset=UTF-8 to Content-Type: it is causing a server I do not control to return UnsupportedMediaType and fails every time.

Please let me know if there is a way to get it to stop.

Specifying the “charset” is actually considered to be more correct for HTTP requests than omitting it.  Bear in mind that network requests from Corona SDK apps have to go through the network layer on the device (or computer in the case of the Simulators) and they may add things that are considered to be “standard”.  Neither report here mentions anything about the operating system or device in use so I can only give general advice and hope it applies (I can’t test the particular circumstances).

Since Corona SDK only tries to fix the charset specification for requests of type “text” you can try specifying that your request is binary and also specify the content type:

local params = { bodyType = "binary", headers = { ["Content-Type"] = "application/json" } } 

Supply this to the network.request() call and you should get the kind of request you need.

+1 exact same problem

Anyone have a fix I do not want Corona to append charset=UTF-8 to Content-Type: it is causing a server I do not control to return UnsupportedMediaType and fails every time.

Please let me know if there is a way to get it to stop.

Specifying the “charset” is actually considered to be more correct for HTTP requests than omitting it.  Bear in mind that network requests from Corona SDK apps have to go through the network layer on the device (or computer in the case of the Simulators) and they may add things that are considered to be “standard”.  Neither report here mentions anything about the operating system or device in use so I can only give general advice and hope it applies (I can’t test the particular circumstances).

Since Corona SDK only tries to fix the charset specification for requests of type “text” you can try specifying that your request is binary and also specify the content type:

local params = { bodyType = "binary", headers = { ["Content-Type"] = "application/json" } } 

Supply this to the network.request() call and you should get the kind of request you need.