Questions tagged [dotnet-httpclient]

Refers to the System.Net.Http.HttpClient library which is part of the HttpClient package on NuGet, or the .NET 4.5 library.

System.Net.Http.HttpClient is a general purpose HTTP client library, intended for use in REST applications or basic HTTP applications. It includes support for de-serializing responses in JSON and XML.

HttpClient was first released in 2008/9 as part of the WCF Starter Kit, which was released via Codeplex.

That HTTP Client library then graduated to a standalone package available via NuGet.

HttpClient will be subsumed into .NET with v4.5, retaining the fullname, namespace, and API, but changing the strong name.

This tag refers to all versions of that .NET library; It specifically excludes the similarly-named Java HttpClient library.

See also for proper HttpClient lifecycle management and creating typed clients.

2837 questions
1
vote
1 answer

StatusCode: 401, ReasonPhrase: 'Unauthorized' gets displayed when calling a Post Method through HTTPClient using C#

I am trying to access an API's Post method through HTTP Client and passing the AuthToken. When I tried to access in post man I am able to get the response, but when I ran in C#, I got StatusCode: 401, ReasonPhrase: 'Unauthorized' error. I am sharing…
Auro Sarma
  • 441
  • 2
  • 12
1
vote
1 answer

.NetStandard Http SendAsync Never Returns

I am creating a NuGet package to retrieve images from an online API. I am using .NetStandard 1.4 and using System.Net.Http version 4.3.2. Every time I call the Login method to get a token to access the api, the http call never returns and just hangs…
CraftyCoder
  • 55
  • 1
  • 7
1
vote
1 answer

Drupal 7 Service module node resources attach_file end point

I am implementing a Xamarin Form mobile app to allow post photo to Drupal using service module node resources. http://xxxx.com/{endpoint}/node/4/attach_file i able to post from POSTMAN with I tried to implement with c# HttpClient but keep getting…
Lee Yeong Guang
  • 146
  • 1
  • 6
1
vote
0 answers

Xamarin - C# - HttpClient

I have a question regarding httpclient, i have a node.js rest api and Im trying to post (send) the user info to the service in order to insert to a database. the service is ok i tested manually and with postman. But im using vs2017 xamarin and to…
1
vote
0 answers

How to post MultipartFormDataContent (with attached files) to REST API?

I have an api in asp.net mvc: public class UploadController : Controller { ... public ActionResult Post(UploadModel uploadModel) I wish to call this api from a test client, attaching files. using (var httpClient = new HttpClient()) …
Anders Juul
  • 2,407
  • 3
  • 34
  • 56
1
vote
1 answer

How to deserialize JSON from Web API to class

so I'm a beginner for JSON and I'm having a hard time to put it in a class from a web API. I used postman to get this so far: { "$id": "1", "id": 1, "name": "Quick Entry", "description": "General", "trackerNumber": 1, …
Marq
  • 15
  • 4
1
vote
1 answer

ASP.NET Core Web API calling other Web API using Client Certificate getting 401

I have been trying to add a client certificate to the HttpClient in a .NET Core 1.1 WebAPI for the past 20 minutes and can not figure out what the issue is. When I debug the program and check to see if the certificate was attached with the handler,…
1
vote
0 answers

HttpClient returning garbage in UWP app

I have a regular .NET Framework class library that successfully calls the Twitter REST API and returns the JSON data returned from the API. This library was copied to a UWP app inside a Universal Windows class library. Everything compiled out of the…
TheHvidsten
  • 4,028
  • 3
  • 29
  • 62
1
vote
0 answers

How to use HttpClient safely in ASP.NET MVC

One thing that I understood the best practice in using HttpClient is to use a single instance of it in my project (e.g, Here) Now I have an ASP.NET MVC project where I am using HttpClient to consume a REST API. I created a client like below: public…
Mustafa Shujaie
  • 1,447
  • 1
  • 16
  • 30
1
vote
1 answer

Response Status code 400:Bad Request because of posting data with large size (httpclient)

I'm sending a form contains a file and a string to a webservice method via httpclient right as below: using (FileStream fs = File.Open(FileFullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (var client = new…
Parsa Saei
  • 1,263
  • 5
  • 21
  • 38
1
vote
0 answers

HttpClient timing out requests after being active for sometime

I am using a single instance of System.Net.Http.HttpClient to send requests from a windows service to multiple RESTful API's. I ran into a strange issue where some of the HTTP requests are timing out at more or less regular intervals. I get lots of…
M22an
  • 1,242
  • 1
  • 18
  • 35
1
vote
1 answer

Getting Location of Created Object from AspNet WebApi with HttpClient

I got an Service to Post Data and Returning Location of Created Object public IHttpActionResult Post([FromBody]ErbrachteLeistung value) { int newLeistungId = service.AddErbrachteLeistung(value); return…
Sebastian Mehler
  • 418
  • 6
  • 15
1
vote
0 answers

.Net core Httpclient excutes twice and results in duplicate request

I am using http client to post payment data to spreedly and charge a credit card. The problem that I am facing is that in some cases its retrying the request second time after 3 secs. The first request has been successful and the card was charged…
1
vote
0 answers

save HttpClientHandler and re use it

hi i'm using "instasharper" and when i login to instagram with "instasharper api" i need to save the HttpClientHandler that is use by "instasharper api" for future use and i'm doing this string str =…
1
vote
0 answers

C# httpclient Rest service authentication with AWS authentication for Rest services using WPF app always show Unauthorized

HI Everyone i am trying to authenticate a webservice which is hosted on a Apache server and uses AWS Authentication, i can get the first service running which gets the Access Id and Access Key, the second step is to sign the URL with the access Key…