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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

.NET HttpClient IO Exception The response ended prematurely, with at least XXXX additional bytes expected

I am calling an internal API to get a data stream that I will use. I occasionally receive an IOException that says The response ended prematurely, with at least XXXXX additional bytes expected. It ...
James's user avatar
  • 493
0 votes
0 answers
62 views

How to Use Azure Key Vault for Client Certificate Authentication in .NET's HttpClient? [closed]

Context: I'm working on a .NET application where I need to use client certificate authentication for HttpClient requests. The certificate's private key is stored in Azure Key Vault and is non-...
SOK's user avatar
  • 525
0 votes
3 answers
83 views

Invalid status line when trying to download file in c#

I am trying to download xml from URL from c# code, so i can then load it into datatable. I tried this very simple code public static void run() { string url = "http://www.strava.cz/foxisapi/...
T0biasCZe's user avatar
3 votes
0 answers
56 views

How to configure HttpClient authorization per call [duplicate]

I'm using HttpClient to interface with Dahua facial recognition devices and they require digest authentication. Since each device could potentially have a different credential, and I didn't find a way ...
Loudenvier's user avatar
  • 8,412
0 votes
0 answers
9 views

Update CredentialCache at runtime

I'm using DI for an HttpClient that uses a CredentialCache as it's a linux host that needs to authenticate to a Windows API. I'm setting the credentials as shown below, which works great. My issue is ...
Gargoyle's user avatar
  • 9,680
0 votes
1 answer
45 views

Is it necessary to call Dispose when IsSuccessStatusCode returns false?

Basically I'm wondering if calling Dispose is necessary when IsSuccessStatusCode returns false after calling something like HttpClient.PostAsync, I'm using a static HttpClient so I can't use a using ...
Fawaz Takhji's user avatar
1 vote
1 answer
34 views

Can an HttpClient Get request be executed without reading the response and taking memory

I am using NEST to make a Search call, and everything is working well but I want to do some testing on a non-primary cluster so that I can test if it has enough power to handle our production load ...
DavidG's user avatar
  • 479
2 votes
1 answer
74 views

HttpClient, implement progress when uploading File

I'm working on a UWP app that uploads files to a server using a custom API method. The file upload itself is functional, but I'm having trouble implementing progress tracking during the upload. I've ...
Mariam Khaled's user avatar
1 vote
1 answer
69 views

Consuming Rest API with C# and HttpClient

My code used to work fine which is var verificationRequest2 = WebRequest.Create(AbstractPricing.PaypalWebAddress); verificationRequest2.Method = "POST"; verificationRequest2.ContentType = &...
MyDaftQuestions's user avatar
-1 votes
1 answer
42 views

Is it possible to configure HttpClient in C# to consistently retrieve website meta data without being blocked?

I've set up an HttpClient to retrieve meta data from websites to build a preview when a url is posted in a user message to my website. This works with links to most sites but a significant number do ...
Alex Cooper's user avatar
0 votes
1 answer
45 views

Http Client Request with Certificate throws exception when trying to read a .NET Core endpoint

I have an ASP.NET Core Web API host which is running on kestrel web host server. I'm trying to add authentication based on client certificate. From .NET Core documentation I understood that by adding ...
Vijay Wilson's user avatar
-1 votes
0 answers
36 views

can we set ca cert in httpclient handler dotnet

So im using HttpClientHandler to set up tls connection var handler = new HttpClientHandler(); var cert = new X509Certificate2(clientCertKeyFilename, certPassword); handler.ClientCertificateOptions = ...
dibii's user avatar
  • 27
0 votes
0 answers
35 views

An .NET API; how to respond to large multi-form request without closing connection?

Consider this client request: var content = new MultipartFormDataContent(); var stream = new FileStream("c:\10GB.zip", FileMode.Open, FileAccess.Read); content.Add(new StreamContent(stream), ...
Jonas Rembratt's user avatar
1 vote
1 answer
90 views

C# HttpClient calls get TaskCanceledException when I pause on breakpoints overly long

I'm working on VS2022, and my code makes many HttpRequests for logging purposes. They are all async calls you can see in the screen shot. I will pause on a breakpoint and not get back til many ...
Daniel Williams's user avatar
0 votes
0 answers
43 views

C# HttpClient abort request after receiving the headers

My feed processing application is fetching third party json feeds in a regular interval and I want to decrease network and memory consumption by caching the last processed feed and skipping the ...
wavedeck's user avatar
2 votes
1 answer
93 views

How to access ProgressMessageHandler when creating HttpClient with IHttpClientFactory in WPF app?

Here I have HttpClient that reports back progress: var handler = new HttpClientHandler() { AllowAutoRedirect = true }; var ph = new ProgressMessageHandler(handler); ph.HttpReceiveProgress += (_, args)...
niks's user avatar
  • 619
0 votes
1 answer
177 views

.NET MAUI how to RESTful API POST and get back response

This is a RESTful API question, and my lack of experience and knowledge with this subject will probably force me to use bad terminology / say dumb stuff, so I apologize in advance. What I'm trying to ...
Bob's user avatar
  • 81
0 votes
1 answer
36 views

Unable to call microservice using HttpClient

I am using OpenApi (NSwag) to create the client that uses HttpClient to call a micro service. Now when I run my application from Visual Studio, it works fine and I can call my service using HttpClient,...
Ask's user avatar
  • 3,208
1 vote
1 answer
97 views

How to utilize multiple parameters in a httpclient request in ASP.NET Core 7

I am trying to pull multiple products from a shopify API as seen in their curl request in the documentation here: curl -X GET "https://your-development-store.myshopify.com/admin/api/2023- 10/...
Irish Redneck's user avatar
0 votes
0 answers
51 views

Window service API encounter 408 request timeout

I had a window service using .net 4.6 framework that calls keycloak API when timeelapsed. The first call after start and first call after idle for a period would always ended up with 408 request ...
user3411128's user avatar
0 votes
0 answers
45 views

HttpClient obtained from WebApplicationFactory handles request headers with multiple values differently?

I'm playing around with WebApplicationFactory to use it in the integration tests of our API, but it seems like the HttpClient that I obtain from WebApplicationFactory.CreateClient() handles the ...
Roland's user avatar
  • 1
0 votes
0 answers
119 views

Deadlock while debugging using HttpClient

I have to query a external webservice using HttpClient (sending hundreds of requests). I made a classic async await loop using HttpClient but, while debugging, about 5-10% of the time Visual Studio ...
LeBigCat's user avatar
  • 1,737
0 votes
1 answer
25 views

C# Web Request Times Out on SSE

I checked this question, but I am getting the response every time, it's not a closing socket issues also this question. I'm trying to stream from an SSE endpoint, and found this blog which was helpful,...
MikeF's user avatar
  • 805
0 votes
1 answer
68 views

How to retrieve a truly large file using System.Net.Http.HttpClient?

How to retrieve a truly large file using System.Net.Http.HttpClient? Related: Large HTTPResponseMessage causes .NET Core server process to run out of memory Calling HttpClient.GetStreamAsync() doesn't ...
Joshua's user avatar
  • 41.5k
0 votes
1 answer
126 views

HttpClient got error with EstablishSslConnectionAsync at SendAsync method

I have ApiAdapter with using HttpClient to send HTTP requests to my server. to avoid create to many HttpClient, I am using DependenceInjection with singleton mode for "ApiAdapter" class. it ...
huan le's user avatar
  • 263
2 votes
1 answer
62 views

how to mock response from httpclient in c#, Azure functions, how to test

I have a static azure function that has an httpclient inside of a service. public static void MyAzureFunction () { ........... // inside run var service = new Service(...) var result ...
myself's user avatar
  • 133
0 votes
1 answer
51 views

In .NET Core: how to read a json response as list [closed]

I need help to read a Json response with no item's list like a list, using HttpClient. In particular I want to read this object like a list: { "0": { "cik_str": 320193, ...
TempestOwl's user avatar
0 votes
1 answer
50 views

Too many Outbound Connections

I have developed a mobile backend using .Net Core in which we are connecting to different third-party services to get user data and for this purpose, I have implemented Typed Client Approach for HTTP ...
Shabir jan's user avatar
  • 2,335
0 votes
0 answers
42 views

RemoteCertificateNameMismatch when Fiddler is in background

I'm facing an issue that when Fiddler is on, I receive RemoteCertificateNameMismatch exception: Inner Exception 1: HttpRequestException: The SSL connection could not be established, see inner ...
O. H's user avatar
  • 77
0 votes
1 answer
51 views

ASP.NET Core 7 API returns different from the web App

I have been struggling with this issue for days and would like some help with it. I am working on a web app where the UI is separated from the API logic. From UI I send some GET requests using the ...
Patrik's user avatar
  • 413
-2 votes
1 answer
257 views

HttpClient and blocking PostAsync

I know it is a popular C# question. However I think my question is specific. I plan to do two requests to the web server. First request is a long GET. The webserver does not reply immediately, wait ...
Petr's user avatar
  • 1
1 vote
0 answers
43 views

Have you ever seen the request's body in the post to be exchanged between 2 requests, when you use HttpClient in an Async way?

The customer reported that 2 registers exchanged information with each other, and on a thousand requests only 2. Register A has body information about register B and vice versa. That occurred in my ...
PJS's user avatar
  • 48
0 votes
0 answers
117 views

How do I download binary file in dotnet Maui mobile app?

I have a rest endpoint that returns a sqlite database file for my Android app. If I create an empty Sqlite db in the app. The initial load of the db from my web api takes to long. In the past I've had ...
Jay Bowman's user avatar
-1 votes
1 answer
50 views

How can I read the file contents using http synchronously

In an event that is called synchronously, so I can't use await (so no IHttpClientFactory), what is the correct way to read the contents of a file. I am using the following, and it works. But the ...
David Thielen's user avatar
0 votes
1 answer
141 views

Cancellation token does not propagate to controller's action while uploading multipart/form file (ASP.NET Core 7)

I have an ASP.NET Core console application, hosted on the user's PC as a Windows service, which communicates with a remote server for executing some tasks, like uploading a file as a stream from the ...
Fabius's user avatar
  • 147
1 vote
1 answer
56 views

C# Executing http requests in a loop where I want the result but don't want to wait before processing the next loop

I'm writing a method GetComputers() which takes a list of strings which are IP Addresses. From this list of strings I want to be build a list of Computer objects which will have properties IPAddress ...
alalalahehehehhahahaha's user avatar
1 vote
1 answer
49 views

What is the correct syntax for mock.Verify for a protected setup?

I have the following unit test: [TestMethod] public async Task ShouldGetExperimentalValuePost() { //arrange var avd = ActualVesselData.Parser.ParseJson(File.ReadAllText(".\\TestFiles\\...
Lucas Hofman's user avatar
-1 votes
1 answer
45 views

httpClient.GetStreamAsync (add username and password)

In my application I load a .pdf file from a password protected site. This works sometimes and sometimes it doesn't. I suspect that this is due to whether my browser knows the username and password or ...
Paul_412's user avatar
-1 votes
1 answer
53 views

add custom httpMessageHandler to service registration in .net core

I have this registration class as you can see : public static class InternalSymbolServiceRegister { public const string DefaultConfigSectionName = "myService"; public static ...
Ehsan Akbar's user avatar
  • 7,035
1 vote
1 answer
205 views

Handling TaskCanceledException when HttpClient times out

I'm trying to use Microsoft.Extensions.Http.Polly policy handler for retries when TaskCanceledException or http transient errors, but it's not working properly. I wrote the minimal API below just for ...
Sergio Jr's user avatar
  • 367
1 vote
0 answers
407 views

Mexc. Future API. Verify failed

I want to place order in crypto exchange Mexc, but when sending a private request, I get this error: "Signature verification error". I follow the documentation and the rules for forming ...
Flax Mine's user avatar
1 vote
1 answer
143 views

HttpClient and server certificate validation

In my .Net 6.0 application I'm using HttpClient to connect to a remote API service which is secured with SSL/TLS. The server where my application is hosted is running in the on-prem Windows Server ...
Matt's user avatar
  • 23
1 vote
1 answer
120 views

How do I connect to my Notion API integration using .NET HttpClient? I can connect using Postman, but not my application

I can connect to my Notion page using Postman by using the call from text. I am using my internal integration. I added the Authorization and Notion-Version headers. My program is a Blazor Server ...
EngineerDude's user avatar
0 votes
0 answers
62 views

HttpClient gets timeout

I have a bot (console application .NET 8) which run twice a month for 24-48 hours each time. I make 3-4 get/post requests per second and the whole purpose of this bot is to be fast as it can be and ...
O. H's user avatar
  • 77
0 votes
0 answers
14 views

NTLM and Basic Auth Fails - API End Point Call

I am trying to access a Web API using either Basic or NTLM authentication and keep getting an "Unauthorised" return response. The API running on an IIS server and both Basic and windows ...
Buda56's user avatar
  • 25
0 votes
1 answer
46 views

Camera stream with ASP.NET Core 7 Web API buffering/stuttering, any way to improve?

We have a .NET 7 application running on Windows Server with IIS that returns feeds from cameras to a front end but the returned stream is very stuttery compared to the original output viewed in chrome ...
Dan's user avatar
  • 340
-1 votes
1 answer
67 views

C# HttpClient request to invalid address returns "OK" 200 code. Why?

I have a weird problem. Im trying to write very simple c# nunit-based http request tests. But when Im sending GET requests to non-existing endpoints I still get 200 "OK" code? Requests sent ...
PanBocian's user avatar
0 votes
0 answers
71 views

.NET HttpClient.sendAsync is slow

I have performance problem calling a REST API Service. I have a complex system, the client call to the server, the server call to the service. Everything is working, but the request time between ...
Fovezer's user avatar
2 votes
1 answer
83 views

C# Polly combining http error handler, retry, bulkhead and timeout to be used inside HttpClient

I am trying to make some HTTP calls and I want to have retry, timeout, and bulkhead for maximum concurrent connections. This is my attempt. I don't know if the order of the WrapAsync function calls is ...
Node.JS's user avatar
  • 1,089
1 vote
0 answers
71 views

C# HttpClient.GetAsync timeouts for url, whereas browser and Invoke-WebRequest works (with repro)

I've come across a website that seems to resist being read via HTTP/Get with C# but works fine in Firefox, Postman and Powershell and I would really love to understand why. Here is the repro-case in ...
Samuel's user avatar
  • 6,206

1
2 3 4 5
58