Adding Headers and Post data in RESTfull/HTTP Request in C#

后端 未结 1 1070
猫巷女王i
猫巷女王i 2021-02-05 07:38

I\'m having problems with sending POST request in C# and it seems I misunderstood some HTTP basics. So basically I\'m implementing RESTfull service client, whic

1条回答
  •  醉梦人生
    2021-02-05 08:36

    Moving Headers before the request steam works (as per AI W's comment), because the request stream is adding the body.

    The way webrequest is implemented internally, you need to finish the header before writing body, and once its in stream format, its ready to send.

    If you look at the implementation of webrequest in reflector or some such decompiling tool, you'll be able to see the logic.

    Hope this helps

    0 讨论(0)
提交回复
热议问题