Jump to content
Registration disabled at the moment Read more... ×
alank2

TNetHTTPClient and custom header

Recommended Posts

I need to specify a custom header that they have a curl example for.

 

$ curl "https://examplesite"
-H 'Authorization: Token token=key1, btoken=key2'
-X GET

 

The documentation for the TNetHTTPClient says this - can I send the above "Authorization: Token token=key1, btoken=key2" as a custom header using the TNetHTTPClient component?  If so, how?

Sending a Request with Custom Headers

The HTTP client component and the HTTP request component both allow you to set custom headers. The custom headers that you can specify are:

When you execute a request, the THTTPClient.Execute method of the HTTP framework combines the custom headers from the HTTP client component and the corresponding HTTP request component and adds those headers to the final request.

Share this post


Link to post

Would it be:

 

NetHTTPClient1->CustomHeaders["Authorization"]=" Token token=key1, btoken=key2 ";

Share this post


Link to post
2 hours ago, alank2 said:

NetHTTPClient1->CustomHeaders["Authorization"]=" Token token=key1, btoken=key2 ";

Alternatively, these would probably work, too:

NetHTTPClient1->CustHeaders->Value["Authorization"] = "Token token=key1, btoken=key2";
NetHTTPClient1->CustHeaders->Add("Authorization", "Token token=key1, btoken=key2");
TNetHeaders AuthHeader;
AuthHeader.Length = 1;
AuthHeader[0] = TNameValuePair("Authorization", "Token token=key1, btoken=key2");
NetHTTPClient1->Get("https://examplesite", NULL, AuthHeader);

 

  • Like 1

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×