1. Converting a POST Request with JSON Payload
Backend DeveloperBackground
A developer needs to integrate a third-party payment gateway API into a Django application. The gateway documentation only provides cURL examples.
Problem
Manually translating complex JSON payloads and authentication headers into Python requests syntax is slow and error-prone.
How to use
Paste the cURL POST command into the input field, enable 'Pretty-print body' and 'Include comments', and copy the resulting Python code.
curl -X POST https://api.gateway.com/v1/charges -H "Authorization: Bearer sk_test_123" -H "Content-Type: application/json" -d '{"amount": 2000, "currency": "usd"}'Outcome
A clean Python script using requests.post() with a formatted payload dictionary and authorization headers.