Search code examples
ruby-on-railsrubytwitter

twitter error on rails console while using twurl api


I am trying to upload a media on twitter with below command from my rails console .

ActiveSupport::JSON.decode(twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=APPEND&media_id=1037245714940747777&segment_index=0" --file /home/administrator/Downloads/s.mp4 --file-field "media" -t) and Getting the error-: JSON::ParserError: 822: unexpected token at ''

I am getting error of JSON parsning, Please help me to solve this problem.


Solution

  • That's command is not for Rails console, it's for bash shell command line, you can just paste it to the Rails console and run. You can run it from bash shell:

    $> twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=APPEND&media_id=1037245714940747777&segment_index=0" --file /home/administrator/Downloads/s.mp4 --file-field "media" -t