alank2 5 Posted April 26, 2022 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: In the HTTP client component: Accept AcceptCharSet AcceptEncoding AcceptLanguage ContentType UserAgent In the HTTP request component: Accept AcceptCharSet AcceptEncoding AcceptLanguage 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
alank2 5 Posted April 26, 2022 Would it be: NetHTTPClient1->CustomHeaders["Authorization"]=" Token token=key1, btoken=key2 "; Share this post Link to post
Remy Lebeau 1394 Posted April 26, 2022 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); 1 Share this post Link to post