Questions tagged [flurl]

Flurl is a fluent URL builder and wrist-friendly HTTP client library for .NET.

Flurl is a modern, fluent, asynchronous, testable, portable, buzzword-laden URL builder and HTTP client library for .NET.

With a discoverable API, extensibility at every turn, and a nifty set of testing features, Flurl is intended to make building and calling URLs easy and downright fun.

Flurl is available on NuGet in two flavors:

  • Flurl.Http includes all features.
  • Flurl for just the URL builder functionality without the HTTP features.
255 questions
16
votes
2 answers

How can I upload a file and form data using Flurl?

I'm trying to upload a file with body content. Is PostMultipartAsync the only way? On my C# backend code I have this: var resource = FormBind(); var file = Request.Files.First().ToPostedFile(); FormBind reads data from the…
eestein
  • 4,914
  • 8
  • 54
  • 93
16
votes
3 answers

Can't set Content-Type header

I'm having trouble setting the Content-Type on HttpClient. I followed along this question: How do you set the Content-Type header for an HttpClient request? But still no luck. String rcString = JsonConvert.SerializeObject(new RoadsmartChecks() {…
timr
  • 6,668
  • 7
  • 47
  • 79
15
votes
1 answer

Flurl client lifetime in ASP.Net Core 2.1 and IHttpClientFactory

Flurl states that using singleton client is recommended pattern: HttpClient is intended to be instantiated once and re-used throughout the life of an application. Especially in server applications, creating a new HttpClient instance for every…
Karel Kral
  • 5,297
  • 6
  • 40
  • 50
14
votes
3 answers

Flurl and untrusted certificates

Currently I worked on Flurl and I tried to contact an API in https (I am in my lab). So the certificate is not valid and Flurl can't continue to work :/ Here is my error message: Unhandled Exception: System.AggregateException: One or more errors…
Digitag
  • 235
  • 3
  • 5
  • 11
12
votes
1 answer

How can I use proxies for web requests in Flurl?

I have a simple post request using the Flurl client, and I was wondering how to make this request using a proxy using information like the IP, port, username, and password. string result = await atc.Request(url) .WithHeader("Accept",…
snacks
  • 123
  • 1
  • 4
11
votes
8 answers

HTTP Request works in Postman, but not in C# code

I want to do a simple HTTP request in C#, but something is not working and all I got is 403 Forbidden status code. When I try to do same request in Postman, everything works fine. I tried to run Fiddler and see all headers that are being sent by…
modugnico
  • 111
  • 1
  • 1
  • 5
11
votes
3 answers

How do I use Windows Authentication with the Flurl library?

Flurl has methods for doing OAuth and Basic authentication: await url.WithBasicAuth("username", "password").GetJsonAsync(); await url.WithOAuthBearerToken("mytoken").GetJsonAsync(); but how do I do Windows authentication using the currently logged…
mason
  • 31,774
  • 10
  • 77
  • 121
10
votes
2 answers

Posting Multiple Headers with Flurl

Hi I'm using Flurl and I need to set multiple headers for the post and the documentation on the site states to do await url.WithHeaders(new { h1 = "foo", h2 = "bar" }).GetJsonAsync(); I'm not sure what this means, what is H1, H2 ? I'm trying to…
user1012500
  • 1,547
  • 1
  • 16
  • 31
9
votes
2 answers

Blazor 0.6.0 "wipes" Flurl-compatibility?

After updating Blazor from 0.5.1 (with working Flurl) to 0.6.0, calls via flurl throw an exception: WASM: [Flurl.Http.FlurlHttpException] Call failed. Cannot invoke method because it was wiped. See stack trace for details. The project creates a…
Sascha
  • 2,193
  • 3
  • 24
  • 38
9
votes
3 answers

Disable AutoRedirect in FlurlClient

I am using FlurlHttp and I want to disable AllowAutoRedirect for some API calls. I know How can I get System.Net.Http.HttpClient to not follow 302 redirects? WebRequestHandler webRequestHandler = new…
Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
9
votes
3 answers

Flurl.Http custom error

I am making an application where a client does requests to a server. The server is written in node.js and the client in .NET using flurl.Http. When a request on the server fails, it is always usefull to create a custom error message. Something like…
Cerebres
  • 343
  • 3
  • 16
8
votes
2 answers

SSL handshake fails in Xamarin

I'm trying to access my RESTful API to retrieve data from a MySQL database. Everything is set up and works perfectly on my C# WPF project. But when using the exact same code in Xamarin Forms (built for Android) I cannot get a successful SSL…
MadWalnut
  • 111
  • 1
  • 7
8
votes
1 answer

How do I get the message from an API using Flurl?

I've created an API in .NET Core 2 using C#. It returns an ActionResult with a status code and string message. In another application, I call the API using Flurl. I can get the status code number, but I can't find a way to get the message. How do I…
boilers222
  • 1,901
  • 7
  • 33
  • 71
7
votes
2 answers

Getting response header

Used the Flurl to Get response from API. var response = await url.WithClient(fc) .WithHeader("Authorization", requestDto.ApiKey) .GetJsonAsync(); dynamic httpResponse = response.Result; But I cant able to access…
Raghaven 3534
  • 286
  • 1
  • 5
  • 10
7
votes
1 answer

Using c# characters in form url encoded request in flurl

Does anyone know how to send a field with brackets by a url encoded form using flurl? Example: I want to send the foo[bar] field with the "foo" value like this var response = await "https://server/request" .WithHeader("Header1", "headerValue") …
Jose C
  • 317
  • 2
  • 13
1
2 3
16 17