Media/upload error code 38 - media parameter is missing


#1

Banging my head against the wall trying to figure out why this isn’t working for me. I tried twurl so that I could see an example of the format of the web request for the /1.1/media/upload.json API call.

Here is what I believe is the relevant part of my request body (I removed the image bytes for easier reading):

–b9cdcccbc77b1e552aa5f51f216bfb7bc2baea51362184553199b1cab033
Content-Disposition: form-data; name=“media”; filename="image.jpg"
Content-Type: application/octet-stream


–b9cdcccbc77b1e552aa5f51f216bfb7bc2baea51362184553199b1cab033–

In the request header, I set the content type to multipart/form-data and initialized the boundary value to the one above.

In twurl the request body looks almost identical to mine, but whereas the twurl request was successful, I am repeatly getting a 38 error code.

Is there some other logical reason why the Twitter API wouldn’t be recognizing the media parameter in my request, even though it’s there? I’m thinking the code could be a red herring for something else.

Please help Twitter Gods! I’m at my wit’s end.


#2

Well, I figured it out. It was actually a function of my limited knowledge of the go programming language, which is the language I am using to call the API method. After capturing my HTTP request using Wireshark, I observed that my request body was empty. Hence the error that the media parameter was empty. Apparently, the act of reading the request body in go (or at least the way I was doing it) before sending it caused it to be empty when the app actually tried to send it. So I removed my debug code and now I have it working.