Problem encoding HTTP Request

Hi all,

Im having trouble encoding the response for a POST Request which has a xml as the body. The response replaces all special caracters for �…

This is my request body: String.Format(“<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:xsi=‘http://www.w3.org/2001/XMLSchema-instance’ xmlns:xsd=‘http://www.w3.org/2001/XMLSchema’ xmlns:soap=‘http://schemas.xmlsoap.org/soap/envelope/’>soap:Body{0}{1}</soap:Body></soap:Envelope>”, firstDayOfMonth, strLastDayOfMonth)

image

Headers:

Response is a xml:
image

Hey @yuri.santos

Please ensure your POST request specifies the correct Content-Type header, typically application/xml or text/xml for XML data.
Ensure also that your Content-Type header includes the charset, e.g., Content-Type: application/xml; charset=utf-8

You can also try to manual decoding. You can use this:

Dim responseBytes As Byte() = YourHttpResponseContent ' This should be the raw byte array from the response
Dim responseString As String = System.Text.Encoding.UTF8.GetString(responseBytes)

Replace YourHttpResponseContent with the variable that holds your HTTP response content in byte array form, and ensure you’re using the correct System.Text.Encoding

I’ve attempted all the options you mentioned for the ‘header’ argument, but the issue persists. Additionally, I’ve tried manually decoding the response, yet special characters still appear as ‘?’. After consulting with the client, it turns out there was an API problem. It was decoding data as ISO instead of UTF-8, which caused the issue.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.