Home curl command replication using requests in python
Reply: 1

curl command replication using requests in python

deep
1#
deep Published in 2017-12-07 08:06:25Z

I am trying to replicate the below curl command in python using the requests module. The curl command is as follows:

curl -v -k -H "apikey:INTERNAL_TEST" http://api1/publicapi/macro/<sha256> -X POST

I am able to replicate the whole curl command except the letter '-X' before POST.

Please inform me in case more information is required. Thank you in advance.

Oluwafemi Sule
2#
Oluwafemi Sule Reply to 2017-12-07 19:57:07Z

The -X flag in curl is for specifying the HTTP method for your request.

You can used requests.post to make HTTP POST request.

url = 'http://api1/publicapi/macro/<sha256>'
headers = {'apikey': 'INTERNAL_TEST'}

response = requests.post(url, headers=headers)
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.319446 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO