I am having an issue when trying to upload an image to twitter using a bash script and twurl. When I use a variable (which is storing the media_id of the image I want to upload) as the parameter for the "media_ids" that I appended to my status update, no photo gets posted and I receive this error message:

twurl -j -X POST -H upload.twitter.com "/1.1/media/upload.json" -f /root/$imgName -F media > mediaID.txt

local mediaID=$(egrep -o " [0-9]{19}" mediaID.txt)

twurl -X POST -H api.twitter.com "/1.1/statuses/update.json?status=The Astronomy Photo Of The Day (courtesy of NASA) for the day $date is \"$title\". For more details and info check out: https://apod.nasa.gov/apod/astropix.html&media_ids=$mediaID" | jq

“errors”: [ { “code”: 44, “message”: “media_ids parameter is invalid.” } ]

However, when I use the actual media_id value instead of the variable ($mediaID) of the image as the parameter for the "media_ids" that gets appended to the status update, everything works as expected.

Is there some issue with using a variable as a parameter for media_id? I am brand new to twurl and api's and therefore might be missing some basic point. I would really appreciate any help or suggestions on this topic. Thank you!

0

There are 0 answers