How to force WebRequest to send Authorization header during POST

前端 未结 3 1059
醉梦人生
醉梦人生 2020-12-09 08:54

When using WebRequest to send a POST, the Authorization header is not sent with the request even though I have manually set the header and set PreAuthenticate to true, eg:

3条回答
  •  春和景丽
    2020-12-09 09:22

    This drove me bonkers, but eventually found the answer in Adding Headers and Post data in RESTfull/HTTP Request in C#.

    The solution for me was adding the Authorization Header BEFORE writing the request stream.

    Hope this helps.

提交回复
热议问题