Problem with POST media/upload API?


#1

Unable to upload base 64 image

the test call I made was:
Request Url:
https://upload.twitter.com/1.1/media/upload.json

Request Query:
media_data=data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCABQAFADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD6+ooorkKAnAJNeOfGT4qTaFfHQdBMbagMfaJmG5YARwoHduQeelewXH+pbFfHXiUNeeJdWu5t3nvezFt2c8OQP0FcWOqzpwShuzzsxrzpRUYbs6bSfif4ytJHeTVhd7x9y4hUhTnGQRj16V1HhL4yXtvqcd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Z+eRFJCZ6FvQE9+lL8RPH0njPx8dTWQixt28u0ixjbGD1Puep+vtVC31O5sL9ZrKd45VYgFecg8FSOhUjgg8EdazdCCqe7fl9fxJqShJ2jsixZCT7QGZlhjTmSQ8AL7H19KqXFyHupTHu8snCbjn9a9B8JeGtL8e2lx/Zckema1aDdPZHm2kU8B4+pQZ6jkAnjAOBxmveDvFul6z/Zf9g380jD5Gji3Jn/eHGPfNXOjKCuldGdSnOMeZK6O/wD2YRZDxXrEggX7ULaP973ClzlcfUD8q+jVfNeQfA/wVP4V0yW71MqdUvdpnCnIjUfdjB74yST6n2r1OGTOK9LB3hTUZHrYKMqdJRkchZzYTJPSsxg2v6u8EhJ0+0cB07TSdcH/AGR6etSwy7bUv6DNW/B8HlaZAW++yCRz6s3J/nXnTXtZwpv4XdvztbT5tifvNRNyBREoC4GK8v8A2o9VuYvh4mnxStEl9dxwysGI+QAuQcdQSoGK9SFef/HzQJ9e+H92lpG0lzaFbqJFGS2z7wA9dpNei7qLSKxHN7GSifNNnbwMoLsY5MDB/vcdD7+9aD3NvFblolJnLY3HnjuR+lYdrdLPCATj61ZnnRLRS2M4429eOK8+avqeIpKx0vwo1y80j4qaE9mx/wBIuBbyAdHjfhgf5/hX11dSJOFYqM45r5P/AGd/D114g+IEWvMr/YNJy5kI4aYghVB+hJP4etfVYGAB6CunC8yi30Z6mAb9m29mxVwvAqzC+DVUGpIzg10pnacTYuJLYqa2vDzYtIAf+eQX8V4P6iuV0C6DoBnrXQaXMYnaEnoxkT6HG4fng/ia86nNc0Z/L77fqcyeqZ0IodQy4NNRgyhhTx0r0DpPLfF/wX8Oa7qj6hbvcaZLK26YW23Y57naRgH6U+D4H+CBbwx3NteXDRZyzXbDfn1C4H5Yr0+ip9nG97GP1ale/KjO0DRdM0LTotO0mygs7WL7kUS7VGep9yfU1o0UhqjVJJWQd6evWmUAjNAz/9k=

Can anyone help me with this…??


#2

What error are you receiving?

Are you setting the correct Content-Transfer-Encoding and Content-Type?


#3

“error”:“media type unrecognized.”…

moreover am new to this. I would highly appreciate if you could please elaborate the process with an example…

Thank you…


#4

There’s more detail on required headers in our uploading media documentation, including an example (although that uses twurl, and isn’t showing a base64 example).


#5

I have gone through that article but it ai’nt that clear…


#6

Please make sure to use correct multipart/form-data encoding, if you are sure you are doing that correctly and it’s still not working, just leave another reply here and I will try to upload that image myself and check if it works for me.