简体   繁体   中英

Python Requests in Postman Args

I have some problem with postman chrome; i want to convert my code (python language) to postman argument,

r = requests.post('http://localhost/assets/update', json={'id':['abcde'], 'bucket': 'fghij'}, headers={'Authorization':'klmno'})

to postman chrome (post),

  1. Header tab (Authorization : klmno) -- done
  2. then, the body ? < -- problem

i'm trying to solve but, the result is Error decoding JSON data. Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',) JSON data extracted from the request

{'id':['abcde'], 'bucket': 'fghij'} is not JSON, it's a Python dictionary which requests converts to JSON for you. You need to use the result of json.dumps({'id': ...}) as the body in Postman. You will note it has double quotes instead of single.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM