bruno icon indicating copy to clipboard operation
bruno copied to clipboard

Convert curl commands to request.

Open sanskar-mk2 opened this issue 2 years ago • 17 comments

In Insomnia, whenever you post a curl request to the url bar, it autofills the headers/url/parameters/creds accordingly to that curl request. It is very important feature since curl is very universal to http requests. You can copy curl directly from browser.

  • [x] Import Curl when creating a new request
  • [x] Switch to curl mode automtically when a curl command is pasted in NewRequest modal
  • [ ] Allow importing of curl when a curl command is pasted in an already opened tab

sanskar-mk2 avatar Oct 04 '23 10:10 sanskar-mk2

+1

In addition, an "Import from curl" option on the directory menu (next to "New request") should be added, to make it obvious that Bruno has this feature.

cvmocanu avatar Oct 06 '23 10:10 cvmocanu

If you can't export to curl, that would also be great to have added. Apologies if it's already a feature, I couldn't see any obvious place in the docs that point that out & GOOG simply pointed me here.

davidsr2r avatar Oct 10 '23 11:10 davidsr2r

@sanskar-mk2 @helloanoop @cvmocanu I'll start working on this issue.

snippetkid avatar Oct 16 '23 10:10 snippetkid

A quick update, I'm through with the changes for this and is currently working on a bug while updating headers from the curl command.

snippetkid avatar Oct 26 '23 05:10 snippetkid

Would love to see a teaser video :)

helloanoop avatar Oct 26 '23 07:10 helloanoop

https://github.com/usebruno/bruno/assets/16718733/2f1caea9-ffee-4e29-998a-f96d8017109c

@helloanoop Here is what it looks like now. Please pass on review comments.

snippetkid avatar Oct 30 '23 12:10 snippetkid

Curl Import functionality is now available in 1.1.0 🎉

helloanoop avatar Nov 03 '23 16:11 helloanoop

@helloanoop it would be good to also have a curl script generated on an existing request. Postman has this feature and it is very handy to show the output of an API call

girishkumar9 avatar Nov 14 '23 06:11 girishkumar9

@girishkumar9 that is already implemented: hover your mouse cursor over a request in the left-side tree, click the 3 dots, Generate Code, Shell-Curl.

cvmocanu avatar Nov 14 '23 08:11 cvmocanu

On Apple M1 Pro with Ventura 13.5.2- All attempts to use the create new request with curl error out. Window with error disappears to quickly to copy the error.

tbkahuna48 avatar Nov 29 '23 21:11 tbkahuna48

@girishkumar9 that is already implemented: hover your mouse cursor over a request in the left-side tree, click the 3 dots, Generate Code, Shell-Curl.

Unfortunately it doesn't work properly with variables. I have the base url in an environment variable and the export doesn't recognize the url.

Edit: the problem seems to be that I used "." in the variable names

koljatm-edeka avatar Jan 27 '24 16:01 koljatm-edeka

@helloanoop I was trying to import a curl but the request url is not properly appearing in the URL field, I tried multiple times, different URLs are coming. is there any debugger or someway that I can see what might be causing it? I tried importing from the collection tab(sidebar) and also in the request window(by clicking on '+').

hp77-creator avatar Feb 23 '24 07:02 hp77-creator

I kind of need to re-import from curl on an existing request. Making a new request for every time I want to import curl is really unwieldy.

Aeolun avatar Mar 18 '24 03:03 Aeolun

Your Bash parser doesn't handle ANSI-C quoted strings, which browsers output when generating curl when some part of the request (namely the body) contains a control character, a non ASCII character or a single quote.

https://github.com/ChromeDevTools/devtools-frontend/blob/c9afdb4745a76866f7486be0e5cdd4e2b270d8af/front_end/panels/network/NetworkLogView.ts#L2090-L2099

You can use https://www.npmjs.com/package/shlex which does

verhovsky avatar Mar 21 '24 18:03 verhovsky

Just found Bruno. Really like it but I wish import from cURL was a little easier for when I need to do it repeatedly. A keyboard shortcut would go a long way. Or a magic textbox that recognizes when the pasted string starts with "curl " and does the right thing. To make this really seamless would be nice if the request name was optional or auto-generated. Thanks for creating this tool!

mivanov avatar Mar 26 '24 20:03 mivanov

It would be nice if it wasn't so many clicks in. In Insomnia pasting a curl command into the url bar would prompt you to import it as a new request. It also had import from curl as an option from under the add menu directly.

jwetzell avatar Apr 06 '24 00:04 jwetzell

Yeah. When working as QA I need to import a lot of curl requests during the day, just to make some minor adjustments and run them. I don't want to create and save a new request in my collection each time I just want to import something from my browser.

Like stated before, both Insomnia and postman "overwrite" the current request when you paste a curl script right into the URL bar. Would love to have the same functionality in Bruno

skoruppa avatar May 08 '24 07:05 skoruppa

Closing this issue since the core functionality for importing Curl has been implemented. Additionally, the Curl importer has seen several updates over the past few months.

If you have suggestions for improvements, please feel free to raise a new issue with specific details.

helloanoop avatar Sep 04 '24 21:09 helloanoop

I think there is a problem, for example I put the curl below curl --request POST 'localhost:8181/api/generateFile?uid=67176bc0b34ba4009e2a7032' But, it did not add the request type (POST) and after I changed it to POST still gave error on request(415) while curl was working.

emirozmen07 avatar Oct 25 '24 08:10 emirozmen07

this was lost at some point, right? there is no curl import anymore since there is no modal when clicking new request.

ps; VSCode extension

Image Image

ltouro avatar Oct 28 '25 18:10 ltouro

@ltouro

We need to add it in the context menu in VSCode. However, you can click on the Code Icon in the URL Bar to access it

Image

helloanoop avatar Oct 29 '25 08:10 helloanoop

@helloanoop you are talking about 'exporting to curl', correct? I'm talking about 'import to bruno, from curl', which was the OP ask.

A common pattern is use the 'copy as curl' in the network tab of the browser developer tool and paste it in the HTTP client.

ltouro avatar Oct 29 '25 19:10 ltouro