python - Python(Django)获取响应API不起作用
问题描述
我的代码无法将数据发布到 Get Response: Getting authentication errors on the headers (Response on terminal)
。已与 GR 交谈,他们可以看到流量,但建议代码错误。
这是POST代码:
import requests
from django.db import models
from elissa.functions import get_async_web_response, get_async_web_response_no_decode
def post_lead(self):
data = '{ "name": "' + self.first_name + '", "email": "' + self.email + '", "campaign": { "campaignId": "xxxxx" }, "ipAddress": "' + self.ip + '", }'
headers = {"X-Auth-Token": "api-key xxxxxxxxxxxx","Content-Type": "application/json"}
get_async_web_response_no_decode("https://api.getresponse.com/v3/contacts", "POST", data=data, headers=headers)
print "post lead data: " + data
headers = requests.post('https://api.getresponse.com/v3/contacts')
print headers.content
response = requests.get('https://api.getresponse.com/v3/contacts')
print response.content
以下是错误日志:
This is the error i get back:{
"httpStatus": 400,
"code": 1021,
"codeDescription": "There is something wrong with your request headers",
"message": "Unsupported `ContentType` header.",
"moreInfo": "https://apidocs.getresponse.com/en/v3/errors/1021",
"context": {
"sentHeaderValue": "",
"supportedHeaderValues": [
"application/json",
"application/x-www-form-urlencoded",
"multipart/form-data"
]
},
"uuid": "edaa9637-2fb0-4933-9da6-f2b3bacfeaf2"
} { "httpStatus": 401, "code": 1014, "codeDescription": "身份验证过程中出现问题,检查标头!", "message": "不支持的身份验证方法", "moreInfo": " https://apidocs. getresponse.com/en/v3/errors/1014 ", "context": [], "uuid": "a0af5b3f-101e-41de-b6b8-bba310bd40ba"
希望您能提供帮助,如果您需要更多信息,请告诉我。
干杯
解决方案
推荐阅读
- powershell - 在 Powershell 中从 CSV 中删除标头
- excel - 使用 VBA 填充 Zillow 搜索框(Zillow 是基于反应的网站)
- c# - 所需的数据注释抛出错误而不是验证客户端
- c# - 将两个不同的 JSON 对象 FromBody 传递给控制器
- mongodb - 当我运行 docker compose 时,我的 golang(摄取)容器无法显示“建立 Mongo 会话时出错”
- spring-mvc - 在“java.util.LinkedHashMap”类型的对象上找不到 - 也许不是公开的?
- java-8 - WebSphere 9 无法启动或无法启动应用程序
- java - Android后台服务导致很多崩溃
- python - 如何在新数据框中剪切和粘贴同一列作为下一列?
- javascript - 使用 react-rails 和 react-jss 服务器端渲染复制样式