Hi I have installed postman and I can post data to my server now I need to post data in python code. here is the postman:
and it is working I can post the data so I want to know how I can post it in my python using request. post.
CodePudding user response:
I'd recommend the requests
library. Here is the documentation for creating POST requests.
import requests
post_headers = {'Content-Type': 'application/x-www-form-urlencoded'}
post_data = {'userIds[0]' : 'A', 'userIds[1]' : 'B'}
resp = requests.post('url', headers=post_headers, json=post_data)
If you have something like and Auth-Token
, include it in the post_headers
.