-1

I want to use the pushbullet api (v2/push) for pushing messages, but if I include '%' character inside title or body the server gives me the following error:

{"error":{"type":"invalid_request","message":"Failed to decode urlencoded POST form body.","cat":"~(=^‥^)ノ"}}

How can I fix this problem?

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

1 Answers1

0

x-www-form-urlencoded is not the most straightforward of formats. You can probably use curl with the --data-urlencode option. You can also try encoding your values with this tool: http://meyerweb.com/eric/tools/dencoder/

That should produce urlencoded output, for instance your request would look more like:

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'
Chris Pushbullet
  • 1,039
  • 9
  • 10
  • i did test such like [curl –u token: https://api.pushbullet.com/v2/pushes --data-urlencode 'type=note&title=TITLETEXT&body=%BODYTEXT'] it also give error T. T – jinah Jul 21 '15 at 02:15
  • i wanna use this request on script. so i cant use http://meyerweb.com/eric/tools/dencoder/ this option – jinah Jul 21 '15 at 02:17
  • That's now how to use --data-urlencode, you need one --data-urlencode for each key-value pair like --data-urlencode "type=note" --data-urlencode "body=%BODYTEXT" I think. I don't use curl much. – Chris Pushbullet Jul 21 '15 at 06:33