钉钉企业内部接口开发,使用 Python Post 数据报错 500

2018-06-07 17:22:48 +08:00
 gimp

我用 Python 来处理钉钉的服务器端接口

现在遇到一个问题,申请 token 后,get 请求都是能用的,post 数据就会报 500 错误

之前发的接口数据字段多,怕参数哪里写的不对,于是使用了(获取用户待审批数量)接口测试找原因,这个接口只需要传递一个 userid

https://open-doc.dingtalk.com/microapp/serverapi2/ui5305

access_token = "xxxxxxxxxx"
url = 'https://oapi.dingtalk.com/topapi/process/gettodonum?access_token=%s' % access_token

data = {
    "userid": "manager4012"
}

headers = {
    'Content-Type': 'application/json'
}

r = requests.post(url, data=json.dumps(data), headers=headers)
print(r.text)

报错:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>500 Internal Server Error</title></head>
<body bgcolor="white"><script>
with(document)with(body)with(insertBefore(createElement("script"),firstChild))setAttribute("exparams","category=&userid=&aplus&yunid=&asid=AQAACADXmhdb3r3FKQAACACKRiLMGAxPpg==",id="tb-beacon-aplus",src="//g.alicdn.com/alilog/mlog/aplus_v2.js")
</script>

<h1>500 Internal Server Error</h1>
<p>The server encountered an internal error or misconfiguration and was unable to complete your request.</body>

headers utf-8 也指定了,json 字符串也转换了

纠结一两天,文档,demo 找了不少,很是不能理解一个 post 过去直接 500 错误,没思路了,特来求助

3359 次点击
所在节点    Python
4 条回复
kunluanbudang
2018-06-07 18:41:10 +08:00
500 是他们服务端问题
gimp
2018-06-07 20:36:43 +08:00
@kunluanbudang 是这么个理儿,但是... 他们不检测自己 API 可用性的吗...
kinghui
2018-06-07 20:50:08 +08:00
不确定钉钉的 access_token 什么格式,但是这段代码唯一有问题的可能就是 access_token 没进行 URLEncode
kunluanbudang
2018-06-07 21:43:38 +08:00
@gimp

国内的开放 API 都这尿性

喂屎💩给别人吃,以后你会遇到更多


不是 KPI 的事情,完全没动力做好

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/461265

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX