From HttpClient, can I save/copy the request to share with someone?
Is there a way to copy raw request details?
For example, I'm looking for a similar output like:
- in Bruno you right-click a request and click "Generate Code"
- in Postman you click the "view code" button on a request
Thanks
16 Replies
No,
HttpClient
is neither Postman nor Bruno
It's used to make HTTP requests to fetch or send some data
Not to share those requests in a human-readable or reproductible format
You can maybe code this functionality yourself, if you wanti know HttpClient is neither Postman or Bruno, it was an example of what data I want
The only way I can think of is to construct the
HttpRequestMessage
and use that to find info before using HttpClient
to send
https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httprequestmessage?view=net-8.0HttpRequestMessage Class (System.Net.Http)
Represents a HTTP request message.
I believe
HttpClient
disposes the request on send, so make sure you pull out info before you do thatyeah ok, I thought maybe I was overlooking some helpful inbuilt function like .DumpRequest() or something
good enough: https://stackoverflow.com/a/70598012
Stack Overflow
How to get verbose info of the HTTP request from HttpClient like th...
I am writing a WinForms program (C#) using System.Net.Http.HttpClient to download webpages.
I'd like to get verbose info of the HTTP(S) requests like the following from libcurl:
* Trying xxx.xxx...
that gets the response, not the request
oh woops
didnt read it close enough
but you basically can do the same with
HttpRequestMessage
ill give it a try, thanks
tbh i really thought there would be a native function
You're the first person I heard of that would use it lol
really? i've had plenty of requests from support teams and such to share the raw request
sometimes i use wireshark or fiddler to get it, but that's an annoying extra step I was trying to reduce
GitHub
GitHub - amingolmahalle/HttpClientToCurlGenerator: A NuGet package ...
A NuGet package for generating curl script of HttpClient in .NET ( C# | CSharp | Dotnet ) supported features: Post, Get, Put, and Delete. content types: application/json, text/xml, application/x-w...
cool
you can intercept the request before it goes down the pipeline with a DelegatingHandler
it will give you headers, verb, version, url, body etc
something like this: