在Python3脚本中附加XML正文内容

时间:2018-10-15 20:39:33

标签: python-3.x

#!/usr/bin/python3

import requests

url = "https://test.test.com/api/dashboards

querystring = {'user' " 'bob'}

payload = "<?xml version =\"1.0\" encoding=\"UTF-8\"?>\r\n  
the_remaining_body_pasted_from_Postman_snippet"

headers = {'Content-Type' : "application/xml"}

response = requests.request("POST", url, data=payload, headers=headers, 
params=querystring, auth=('user', 'pass'))

print(response.text)

ResponseBodyParseException“ name =”请求正文解析“ statusCode =” 400“ 取消整理文件时发生错误 内部异常:com.ctc.wstx.exc.WstxIOException:无效的UTF-8中间字节0x6e(在char#3126,字节#37)

该调用可在Postman中使用,但Postman在Python3中提供的摘录似乎无法在Ubuntu中粘贴到.py文件中。

谢谢

0 个答案:

没有答案