ServiceStack JsonServiceClient - Custom HTTP headers not sent

I am trying to send custom HTTP headers using JsonServiceClient, but headers are never sent in the request.

I use:

JsonServiceClient client = new JsonServiceClient (baseUri); client.Headers.Add ("X-Parse-Application-Id", "XXXXXX"); client.Headers.Add ("X-Parse-REST-API-Key", "XXXXXX"); 

Any idea?

+6
source share
2 answers

You have not made a request yet. Headings are added here when you make a request.

An alternative way to add headers is to use query filters, for example:

 client.RequestFilter = httpReq => { httpReq.Headers.Add ("X-Parse-Application-Id", "XXXXXX"); httpReq.Headers.Add ("X-Parse-REST-API-Key", "XXXXXX"); }; 

Which actually does the same thing.

+8
source

Here is another way to do it.

 _client.RequestFilter = httpReq => httpReq.Headers.Add("X-CUSTOM", "hello"); 
0
source

Source: https://habr.com/ru/post/949309/


All Articles