ServiceStack JsonServiceClient - 未发送自定义 HTTP 标头
问题描述:
我正在尝试使用 JsonServiceClient 发送自定义 HTTP 标头,但从未在查询中发送标头.
I'm trying to send custom HTTP Headers with a JsonServiceClient but headers are never sent in the query.
我正在使用:
JsonServiceClient client = new JsonServiceClient (baseUri);
client.Headers.Add ("X-Parse-Application-Id", "XXXXXX");
client.Headers.Add ("X-Parse-REST-API-Key", "XXXXXX");
有什么想法吗?
答
您还没有提出请求.在此处添加标头提出请求.
You haven't made a request yet. The Headers get added here when you make a request.
另一种添加标头的方法是使用请求过滤器,例如:
An alternative way to add headers is to use the Request filters, e.g:
client.RequestFilter = httpReq => {
httpReq.Headers.Add ("X-Parse-Application-Id", "XXXXXX");
httpReq.Headers.Add ("X-Parse-REST-API-Key", "XXXXXX");
};
有效地做同样的事情.