Python Postman 参数中的请求

Python Requests in Postman Args

我对 postman chrome 有一些问题; 我想将我的代码(python 语言)转换为 postman 参数,

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

to postman chrome (post),

  1. Header 选项卡(授权:klmno)-- 完成
  2. 那么,body? < -- 问题

我正在尝试解决,但结果是 JSON 数据解码错误。错误:JSONDecodeError('Expecting value: line 1 column 1 (char 0)',) JSON 从请求中提取的数据

{'id':['abcde'], 'bucket': 'fghij'} 不是 JSON,它是一个 Python 字典,requests 为您转换为 JSON。您需要使用 json.dumps({'id': ...}) 的结果作为 Postman 中的正文。您会注意到它有双引号而不是单引号。