I am calling a REST web service using TRestClient and TRestRequest. This API requires a token to be passed in the header section. This token contains characters such as '/' and '+'. I am using the rest request params AddHeader function to add the token string to the header.

I am using Fiddler to inspect the traffic, and when I call the service using SoapUI, the token is sent with the characters intact. When I send the request using my application or the Embarcadero REST Debugger tool, it converts those characters to their hex value and will send %2F instead of '/' and the server responds as unauthorized.

Is there a setting that will prevent the TRestRequest AddHeader method from converting those characters to hex? I've tried modifying other header values, such as the AcceptEncoding and AcceptCharset, but no luck so far. In SoapUI and Postman just simply adding the header field and pasting in the token string presents no problems.

After looking at it more in the designer I stumbled on the TRestRequestParameter Options, which includes poDoNotEncode. So when adding the header parameter, I saved the TRestRequestParameter option and added the poDoNotEncode. After that it goes through normally.

Adam Martin wrote:
I am calling a REST web service using TRestClient and TRestRequest. This API requires a token to be passed in the header section. This token contains characters such as '/' and '+'. I am using the rest request params AddHeader function to add the token string to the header.

I am using Fiddler to inspect the traffic, and when I call the service using SoapUI, the token is sent with the characters intact. When I send the request using my application or the Embarcadero REST Debugger tool, it converts those characters to their hex value and will send %2F instead of '/' and the server responds as unauthorized.

Is there a setting that will prevent the TRestRequest AddHeader method from converting those characters to hex? I've tried modifying other header values, such as the AcceptEncoding and AcceptCharset, but no luck so far. In SoapUI and Postman just simply adding the header field and pasting in the token string presents no problems.