【问题标题】:pushbullet api decoding (v2/push)pushbullet api 解码 (v2/push)
【发布时间】:2015-07-21 01:51:24
【问题描述】:

我想使用 pushbullet api (v2/push) 推送消息,但如果我在标题或正文中包含 '%' 字符,服务器会给我以下错误:

{"error":{"type":"invalid_request","message":"无法解码 urlencoded POST 表单正文。","cat":"~(=^‥^)ノ"}}

我该如何解决这个问题?

request: curl https://api.pushbullet.com/v2/pushes -k -u token: -d type=note -d title="%test" -d body="%%test" -X POST

【问题讨论】:

    标签: zabbix pushbullet


    【解决方案1】:

    x-www-form-urlencoded 不是最直接的格式。您可能可以将 curl 与 --data-urlencode 选项一起使用。您也可以尝试使用此工具对您的值进行编码:http://meyerweb.com/eric/tools/dencoder/

    这应该会产生 urlencoded 输出,例如您的请求看起来更像:

    curl -u token: https://api.pushbullet.com/v2/pushes --header "Content-Type: application/x-www-form-urlencoded" --data-binary 'type=note&title=TITLETEXT&body=%25BODYTEXT'
    

    【讨论】:

    • 我确实测试过 [curl –u token: api.pushbullet.com/v2/pushes --data-urlencode 'type=note&title=TITLETEXT&body=%BODYTEXT'] 它也给出了错误 T.T
    • 我想在脚本上使用这个请求。所以我不能使用meyerweb.com/eric/tools/dencoder这个选项
    • 这就是 --data-urlencode 的使用方法,每个键值对都需要一个 --data-urlencode,例如 --data-urlencode "type=note" --data-urlencode "身体=%BODYTEXT" 我想。我不怎么用 curl。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多