Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The API I'm trying to call requires that I do a POST but with an empty body. I'm new to using the WCF Web API HttpClient and I can't seem to find out the write code that would do a post with an empty body. I find references to some HttpContent.CreateEmpty() method, but I don't think that is for the Web API HttpClient code since I can't seem to find that method.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
587 views
Welcome To Ask or Share your Answers For Others

1 Answer

Use StringContent or ObjectContent which derive from HttpContent or you can use null as HttpContent:

var response = await client.PostAsync(requestUri, null);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...