Watch, Follow, &
Connect with Us

Welcome, Guest
Guest Settings
Help

Thread: TRestRequest Header Parameter Convert Characters to Hex Values


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Aug 11, 2017 11:46 AM Last Post By: Adam Martin Threads: [ Previous | Next ]
Adam Martin

Posts: 3
Registered: 3/21/12
TRestRequest Header Parameter Convert Characters to Hex Values  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 11, 2017 10:09 AM
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.

Any help would be greatly appreciated, thanks!
Adam Martin

Posts: 3
Registered: 3/21/12
Re: TRestRequest Header Parameter Convert Characters to Hex Values  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 11, 2017 11:46 AM   in response to: Adam Martin in response to: Adam Martin
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.

Any help would be greatly appreciated, thanks!
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02