我正在尝试使用尝试从我方发送有效载荷的请求来发送数据,要求将日期格式设置为“ \ / Date(1532010600000)\ /”
我正在尝试制作一个自定义有效负载,该负载将通过请求发送:
payload = {
"GW_MeetingID": "1231324654654",
"AltID": "This is ALT ID",
"MeetingSubject": company,
"MeetingComment": "",
"RoomID": "xxxxx",
"TimeZoneId": "Dateline Standard Time",
"Organizer": organiser,
"Start": "\\/Date(1532010600000)\\/"
}
此处的键应为“ \ / Date(1532010600000)\ /”而不是“ \\”,并使用额外的“ \”作为转义字符。当我尝试打印此有效负载时,它将显示带有“ \\”的开始键的值,而我试图向其发送响应的api不接受。它仅接受“开始”键作为“ \ /日期(1532010600000)\ /”
我尝试过的解决方案是使用.encode('utf-8'),然后使用.decode('unicode_escape')对其进行解码。但是字典仍然对“ \\”
有相同的响应如何使此有效载荷在开始键中包含“ \”?
payload = {
"GW_MeetingID": "1231324654654",
"AltID": "This is ALT ID",
"MeetingSubject": company,
"MeetingComment": "",
"RoomID": "e3e63148-5e4f-426e-98de-dec1687c9930",
"TimeZoneId": "Dateline Standard Time",
"Organizer": organiser,
"Start": "\\/Date(1532010600000)\\/"
}
print (payload)
# print (json.dumps(payload))
# a = (ast.literal_eval(payload))
headers = {'Content-Type': 'application/json'}
r = requests.post(url, data=json.dumps(payload), headers=headers)
print (r.text)