0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

C# でリクエストヘッダを指定しながら HTTP POST 送信

Last updated at Posted at 2022-10-27
using System.Text;
using System.Net.Http;
HttpClient client = new HttpClient();

string url = "https://httpbin.org/post";

string parameters = "{" +
    " \"foo1\" : \"bar1\" ," +
    " \"foo2\" : \"bar2\" ," +
    " \"foo3\" : \"bar3\"  }";

var content = new StringContent(parameters, Encoding.UTF8, "application/json");å
client.DefaultRequestHeaders.Add("FOO", "BAR");

HttpResponseMessage response = await client.PostAsync(url, content);
var request = new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Post, url);

var body = await response.Content.ReadAsStringAsync();

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?