我正在使用zapier电子邮件解析器中的字段创建一个api post请求,并使用zapier代码Python模块将它们插入到请求中
问题是我似乎无法将输入数据字段输入到请求中。在我尝试插入这些字段之前,请求一直正常工作
例如,“firstName”字段有一个名为“first”的输入_数据字段,当我尝试将其插入到数据中时,它会将其打断,我尝试了几种不同的变体括号、括号等
我没有很多python知识,所以我很确定这是一个语法问题。希望有人能给我指出正确的方向。这里是代码与“Api密钥等删除”谢谢
import requests
'Api-Key': 'hidden',
'Cache-Control': 'no-cache',
'Content-Type': 'application/json',
}
data = '{\n "arrivalDate": "01/19/2021", "departureDate": "01/25/2021", "channelId": hidden, "arrivalTime": "16:00", "departureTime": "10:00", "firstName": input_data("first"), "lastName": "Musetn", "email": "test@gmail.com", "phone": "0177123456789", "notice": "Breakfast, one dog", "adults": 1, "priceStatus": 1, "depositStatus": 1, "language": "en"}'
response = requests.post('https://login.smoobu.com/api/apartment/hidden/booking', headers=headers, data=data)
就像前面提到的注释者一样,您应该让python处理将数据转换为json的问题。请尝试以下方法:
相关问题 更多 >
编程相关推荐