{"errmsg":"不合法的参数","errcode":40035} 叮叮报警写入失败

first try:

import requests



def alert(con):
    url = "https://oapi.dingtalk.com/robot/send"
    querystring = {"access_token":"d8****f3a2a"}

    payload = "{\"msgtype\": \"text\",\"text\": {\"content\": %s,\"at\": {\"isAtAll\": true}}"%con
    headers = {
        'content-type': "application/json",
        'cache-control': "no-cache",
        'postman-token': "44***5"
        }


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

    print(response)
    print(response.text)

 
alert("begin")

 

 

second:

import requests

import json

def alert(con):
    url = "https://oapi.dingtalk.com/robot/send"
    querystring = {"access_token":"d**a"}

    data = {
        "msgtype" : "text",
        "text" : {
            "content" : con,
            "at" : {
                'isAtAll' : True
            }
        }
    }
    json_str = json.dumps(data)
    headers = {
        'content-type': "application/json",
        'cache-control': "no-cache",
        'postman-token': "4***05"

        }

    response = requests.request("POST", url, data=json_str, headers=headers, params=querystring)

    print(response)
    print(response.text)
    

这样就好了, payload = "{\"msgtype\": \"text\",\"text\": {\"content\": %s,\"at\": {\"isAtAll\": true}}"%con 

 payload是json 后的数据,直接用python的 json.dumps()就OK了

 

展开阅读全文

没有更多推荐了,返回首页