Author, here. curlconverter gets about 17k unique users per month. The code generated by this tool is probably in production all over the world. But the codebase needs maintenance! I hired a junior developer (cf512) to do about 40 hours of dev work last month, but that contract has ended and I'd appreciate more volunteers. All the code is open source. I see a few bug reports down thread. Please open tickets. A big th…
Convert Curl Syntax to Python Requests
41–47 of 47 posts
Re: Convert Curl Syntax to Python Requests
#42This is neat, but also seems like a code smell. Do people really need to convert between HTTP request formats/languages much? When I see many independent implementations of an N-to-M mapping, it looks like the perfect use case for a standardized interface, like a DSL. In fact, can't HAR do this? I'd love to be able to just pass a HAR string to any HTTP client library, and have it execute that. Or call "dump_har()" (o…
When reverse engineering or automating an API my workflow will often look like this: 1. Open browser inspector, watch API requests for one I'm interested in 2. Right click, "Copy as cURL" 3. Paste into a text editor, remove some unnecessary headers, re-running the curl command to verify that the headers I removed aren't important 4. Convert into python requests so that I can play with the parameters
Also handy because even well documented API's don't have examples in every language, but most do have examples in curl. So you can easily take those example curl's and dump them out to something programatic in your language.
Re: Convert Curl Syntax to Python Requests
#43OK, I'm not going to lie. I didn't even know you could copy requests from the network tab into curl (or fetch/ powershell/ etc.) like that. Embarrassing! :) Seems pretty useful!
Re: Convert Curl Syntax to Python Requests
#44There's a bit of a hidden feature in Postman that can do this and way more, hit the code button in the right corner and you can convert your web requests to something like a dozen languages: https://i.imgur.com/0qUV8b9.png
Re: Convert Curl Syntax to Python Requests
#45This is neat, but also seems like a code smell. Do people really need to convert between HTTP request formats/languages much? When I see many independent implementations of an N-to-M mapping, it looks like the perfect use case for a standardized interface, like a DSL. In fact, can't HAR do this? I'd love to be able to just pass a HAR string to any HTTP client library, and have it execute that. Or call "dump_har()" (o…
When reverse engineering or automating an API my workflow will often look like this: 1. Open browser inspector, watch API requests for one I'm interested in 2. Right click, "Copy as cURL" 3. Paste into a text editor, remove some unnecessary headers, re-running the curl command to verify that the headers I removed aren't important 4. Convert into python requests so that I can play with the parameters
Plus, you probably have a text editor that knows about JSON, so it's easy to (say) remove keys from a JSON file, or even just keep the keys on separate lines and add/remove entire lines. I haven't seen a text editor (even Emacs!) that was as good at editing shell command parameters. It's a lot easier to quote special characters for JSON, too, compared to quoting special characters for my shell.
Re: Convert Curl Syntax to Python Requests
#46This is neat, but also seems like a code smell. Do people really need to convert between HTTP request formats/languages much? When I see many independent implementations of an N-to-M mapping, it looks like the perfect use case for a standardized interface, like a DSL. In fact, can't HAR do this? I'd love to be able to just pass a HAR string to any HTTP client library, and have it execute that. Or call "dump_har()" (o…
Re: Convert Curl Syntax to Python Requests
#47There's a bit of a hidden feature in Postman that can do this and way more, hit the code button in the right corner and you can convert your web requests to something like a dozen languages: https://i.imgur.com/0qUV8b9.png
Insomnia REST Client converts cURL commands into request sessions too.