Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
113 views

I need to post HTTP API requests whose bodies are given as List<ArraySegment<byte>> (the usual fixed header + variable middle + fixed footer stuff). The .NET Socket can send List<...
DarthGizka's user avatar
  • 4,833
1 vote
1 answer
1k views

The following is the code from where I would return a tuple of response status code and response output. private Tuple<int, string> API_Check(string URL, string reqtype, string reqbody, string ...
ItsMeGokul's user avatar
2 votes
1 answer
2k views

How can I properly extract an HttpResponseMessage Content property (of type HttpContent) in .NET Standard 2.0 plain synchronous manner, acquired after using asynchronous await HttpClient.SendAsync(...
cobrajohngs's user avatar
0 votes
1 answer
2k views

In c# why both HttpClient and HttpContent have headers. What is difference between them. When should I use client headers and when content headers ? CODE EXAMPLE: HttpClient client = new HttpClient(); ...
user avatar
0 votes
0 answers
549 views

I am trying to write unit tests for the following code: m_Client.SendAsync(request).ContinueWith(responseTask => { HttpResponseMessage response = responseTask.Result; try { ...
walruz's user avatar
  • 1,386
0 votes
1 answer
2k views

I'm trying to mock var response = await httpClient.SendAsync(request, CancellationToken.None); but my response.Content is always null. My mock looks like... var httpResponseMessage = new ...
Robert Green MBA's user avatar
0 votes
0 answers
209 views

I'm trying to make a simple translator for chinese website using DeepL Traslator, got the data from Live http header thank in advance --- thank in advance ---- thank in advance thank in advance --- ...
Fouad GoGo's user avatar
0 votes
1 answer
1k views

I need help populating the Body Parameters for the documentation of this endpoint. It shows as empty: I realize that the reason this is happening is because I am currently reading the request body and ...
Brandon Lumsden's user avatar
0 votes
1 answer
266 views

I am new to Web and part of my Web API 2 training is to create an API controller that uses an HttpClient and an HttpContent to read entire website and from that to return only a specific portion to a ...
Sotiris's user avatar
0 votes
1 answer
2k views

I have multiple Attribute classes which need to access the data in an HttpContent (which is in an HttpActionContext's HttpRequstMessage) but I am having issues deciding on the best way to do it. I ...
Aaron T's user avatar
  • 1,102
2 votes
1 answer
710 views

adding new header "If-Match" using (HttpContent content = new StringContent(serializedObject)) { content.Headers.Remove("Content-Type"); content.Headers.Add("Content-...
Samw's user avatar
  • 128
0 votes
1 answer
1k views

I have a custom model binder: public class JsonPolyModelBinder : IModelBinder { private readonly JsonSerializerSettings settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling....
user3689167's user avatar
0 votes
1 answer
5k views

public async Task<T> PostFrom<T>(string baseAddress, string url, string requestbody) { T obj = default(T); //Create the Uri string string request = baseAddress + url; ...
Ahmad Awad's user avatar
0 votes
3 answers
6k views

I am trying to send a POST request to a server.The request gets into the Middleware's Invoke method. However the Content is always null, no matter the type of the object. Sender public async Task&...
Bercovici Adrian's user avatar
-1 votes
1 answer
2k views

I'm trying to POST a data to web using HttpClient but i can't succeed. Here is my JSON web api { "Categories":[ { "CategoryID":1, "Category":"Category 1" }...
Naeem Shah's user avatar
2 votes
3 answers
4k views

I have to compute hash for huge payload, so I am using streams not to load all request content in memory. The question is what are the differences between this code: using (var md5 = MD5.Create()) ...
Jevgenij Nekrasov's user avatar
-1 votes
1 answer
3k views

When using HttpClient, I have read examples (such as this example) that uses DefaultRequestHeaders to set the content type (such as "application/json") of a Post request. I tried to do something like ...
KansaiRobot's user avatar
  • 10.6k
2 votes
1 answer
2k views

I have this code: String json = "{\"name\":\"listFiles\"}"; // Wrap our JSON inside a StringContent which then can be used by the HttpClient class HttpContent httpContent = new StringContent(json, ...
mans's user avatar
  • 18.4k
0 votes
0 answers
3k views

I am trying to use the HttpClient class to call a POST method from my API which is supposed to add Server information to a DB. The way I'm trying to call it is below. But when I step through it to ...
Zybrith's user avatar
0 votes
1 answer
288 views

My question is a follow up on: How can I calculate progress with HttpClient PostAsync? This solution works perfectly. Just remember, if you are using Xamarin, to include the Microsoft.Net.Http nuget ...
user7338313's user avatar
2 votes
2 answers
4k views

I am trying to call the Web api method for saving the File Data.When I debug Webapi method I found that ContentLength is not coming as correct, because of this when i am retrieving the file it is ...
Gorakh Nath's user avatar
  • 9,906
3 votes
1 answer
4k views

I am wanting to take JSON, put it in a StringContent and pass it to my API. From there, i am wanting to deserialize the JSON back over to a class and use it from there. Currently i am getting an error ...
user1732364's user avatar
0 votes
1 answer
90 views

I am trying to make a PostAsync request with c#. The following is my code. static void Main(string[] args) { CookieContainer cookies = new CookieContainer(); ...
Puzzle's user avatar
  • 25
2 votes
2 answers
5k views

If a caller adds HttpContent: using (var content = new MultipartFormDataContent()) { HttpContent additionalContent = StringContent("just a test"); content.Add(additionalContent); Which is then ...
4thSpace's user avatar
  • 44.4k
0 votes
2 answers
2k views

I have just posted this question, which answer came right away. It, in turn, creates the following new question: If my understanding is correct, the StreamContent object, from HttpResponseMessage, is ...
Veverke's user avatar
  • 11.6k