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

Unauthorized response after setting CachePolicy with HttpClient

I am sending a GET request to a server which expects NTLM authentication. For that we set UseDefaultCredentials = true var defaultHandler = new WebRequestHandler { UseDefaultCredentials = true, CachePolicy = new…
Luis Filipe
  • 8,488
  • 7
  • 48
  • 76
1
vote
0 answers

HttpClient SendAsync with Progress output to Console

I'm simply trying to have a basic SendAsync method write it's progress to the console, and even after a bunch of SO answers for GET, I'm not really seeing how this works for POST. The file I'm testing with is ~ 100Mb and when it hits the SendAsync…
Chase Florell
  • 46,378
  • 57
  • 186
  • 376
1
vote
2 answers

Error when using HttpClient inside DelegatingHandler: The request message was already sent. Cannot send the same request message multiple times

In the code snippet below I am trying to implement a DelegatingHandler. You will notice that in the SendAsync method I am deviating from the conventional practice of passing the request to the InnerHandler... base.SendAsync(request,…
July.Tech
  • 1,336
  • 16
  • 20
1
vote
1 answer

iOS Httpclient cannot connect: {System.Threading.Tasks.TaskCanceledException}

I'm building an app with Xamarin Forms. I have no issues with Android, but when I attempt to simulate or deploy the iOS app, my HttpClient can't seem to connect to the server. After the timeout expires, I get a TaskCanceledException. The HttpClient…
Joe
  • 191
  • 1
  • 3
  • 13
1
vote
2 answers

HttpClient request in finalizer in .NET

I'd like to make a HTTP request when an object is being collected by the Garbage Collector. I put a simple call in the finailzer of the class, which works fine as long as the application is not shutting down. When the program is finished and my…
1
vote
3 answers

403 when calling AirBnb api from C#

I've not used HttpClient before so apologies if it's an obvious one. I'm poking about with the airbnb api http://airbnbapi.org/#view-listing-info My understanding of the endpoint is that I don't need an auth token, as this is a public endpoint I'm…
MGDavies
  • 1,024
  • 1
  • 17
  • 30
1
vote
0 answers

.NET multipart data appeared in preamble section

client side is using MultipartFormDataContent with two part of data, one is a file, the other one is some metadata. In each 3 request, there will be 2 request failed due to FileData empty. Client: var client = new HttpClient(new…
Eason Yang
  • 23
  • 4
1
vote
0 answers

C# HttpClient times out when using remote proxy, but works when using local proxy (Fiddler) that is upstream chained to the same remote proxy

I am trying to use HttpClient via a proxy: var httpClientHandler = new HttpClientHandler {UseProxy = true, Proxy = new WebProxy("xxx.xxx.xxx.xxx:6762")}; var httpClient = new HttpClient(httpClientHandler) {Timeout = TimeSpan.FromSeconds(3)}; With…
July.Tech
  • 1,336
  • 16
  • 20
1
vote
1 answer

Getting Bad Request error while updating email category with Office 365 API and HttpClient in C#

I'm trying to to update email category and also mark it as read after that with the help of Outlook 365 API and HttpClient. Following this tutorial. In the tutorial the code is as below to update category and mark as read but, I'm not getting that…
Ashok
  • 1,868
  • 6
  • 36
  • 70
1
vote
0 answers

Why does HttpClient GetAsync() not return in Xamarin?

I'm new to Xamarin and I'm trying to create a cross-platform app where users can login using a JSON API call. A token is then returned on a successful login attempt which I can use in other API's to display user data. It works when I use the same…
Emile
  • 11
  • 4
1
vote
2 answers

How to add headers and parameters for a rest service from xamarin forms c#

User login endpoint (POST Method) https://developer.api.yodlee.com/ysl/restserver/v1/user/login Sample Input cobrandName is passed as path parameter cobSession is passed as Authorization Header loginName and password are passed as form…
Costas Aletrari
  • 387
  • 5
  • 22
1
vote
0 answers

Xamarin Android HttpClient keep alive not working

I am using Xamarin.Android with a PCL. In my PCL, I use a HttpClient to Get or Post HTTP requests to an API. I want to use the same instance of my HttpClient for multiple HTTP requests, and to use the keep-alive. Here is my code for test…
Maxime Esprit
  • 705
  • 1
  • 8
  • 29
1
vote
1 answer

C# httpClient does not return content

public const string CloudApi = "https://www.idxhome.com/restServices/cloud-idx/login"; public const string password = "cloudidx"; public const string clientId = "65912"; public async Task Index() { HttpClient client = new…
George Schneider
  • 13
  • 1
  • 1
  • 5
1
vote
0 answers

Null Point Exception happening in the HttpClient.GetAsync methode

I'm working on a Xamarin.Forms application in which I'm downloading some data from the server and showing them on the screen. This data is downloaded every 5-10 seconds in order to keep the application updated. My code for the data download looks…
1
vote
0 answers

how to send body parameter and file with httpclient in c#

I have web service and i want to send to this web service parameter value&key like token = "" and file client - >>>>>>>>>>>send>>>>>>>>>web service token = "exmple" userfile = sound file web service (get both) >>>>>>>>send>>>>>> client result as…
user2254798
  • 553
  • 2
  • 6
  • 17
1 2 3
99
100