Custom header to HttpClient request

前端 未结 4 1733
走了就别回头了
走了就别回头了 2020-11-27 03:38

How do I add a custom header to a HttpClient request? I am using PostAsJsonAsync method to post the JSON. The custom header that I would need to b

4条回答
  •  隐瞒了意图╮
    2020-11-27 04:32

    I have found the answer to my question.

    client.DefaultRequestHeaders.Add("X-Version","1");
    

    That should add a custom header to your request

提交回复
热议问题