Image upload with status update


#1

I cant able to upload image through status/update end point… but i got media id through media/upload end point… when i make a call with status=“hello”&media_ids=xxxxxxxxxxxxx ,only status wille be updated. can anyone tell me the exact status for this?


#2

That sounds like you are not encoding the values properly. How are you making the request?


#3

connection.setRequestProperty(“Authorization”, authorizationHeader);
connection.setRequestProperty(“Content-Type”, “multipart/form-data; boundary=” + boundary);//No I18N
connection.setDoOutput(true);
String CRLF = “\r\n”;
out = new DataOutputStream(connection.getOutputStream());

        out.writeBytes("--"+boundary+CRLF);
        out.writeBytes("Content-Disposition: form-data; name=\"" + "status" + "\"" + CRLF);
        out.writeBytes(CRLF);
        String status = (String) postBody.get("status");
        out.write(status.getBytes());
        out.writeBytes(CRLF);
        out.writeBytes("--" + boundary + "--" + CRLF);
        out.writeBytes("--" + boundary + CRLF);
        out.writeBytes("Content-Disposition: form-data; name=\"" + "media_ids" + "\"" + CRLF);
        out.writeBytes(CRLF);
        out.write("570567831332397056".getBytes());

#4

(Please indent code with 4 spaces, so it is displayed properly)

A request to the POST statuses/update endpoint should be www-form-encode, this means the body should be something like this: status=foooo&media_ids=bar


#5

Ya i tried it by appending parameter as status and media_ids ,but even though its not working. More over i ve sent content type as “application/x-www-form-urlencoded”

Response:
{“data”:{“errors”:[{“message”:“Could not authenticate you.”,“code”:32}]}}


#6

This looks like your OAuth Code is not capable to deal with www-form-encoded content correctly.


#7

But status updated correctly then y not image doesnt upload?


#8

@RajiitGct,

Did you get this issue fixed?

Even I’m facing the same issue for the last couple of days.

If you have managed to get this fixed, can you please paste the code how the POST request is being framed??