403 Error using .xml Update status with HTTPConnection Post in j2me..

53 views
Skip to first unread message

ScottB

unread,
Dec 2, 2008, 2:47:28 PM12/2/08
to Twitter Development Talk
I keep getting this response to my attempts to post a status update
from an app I'm writing.

<?xml version="1.0" encoding="UTF-8"?>
<hash>
<request>/statuses/update.xml</request>
<error>Client must provide a 'status' parameter with a value.</
error>
</hash>

Everything seems totally in order,

using:
http://twitter.com/statuses/update.xml

I set the content length in the header, then open the HttpConnections
outputstream, write the request bytes, flush it, then check the
response code to send the request in that order.

I'm under the impression that the content body of the request should
be simply:

status=*update_content_string_here*

I've tried testing various different headers, adding the optional
"in_reply_to_status_id" as well, but it just gives me that same 403
error.


Any help or verification that the
http://twitter.com/statuses/update.xml
works for others and that I'm using the correct parameter formatting
would be greatly appreciated.

Thanks

Matt Sanford

unread,
Dec 2, 2008, 4:31:14 PM12/2/08
to twitter-deve...@googlegroups.com
Hello Scott,

    A few things come to mind. Make sure you're correctly setting the Content-Type header like so:

 Content-Type: application/x-www-form-urlencoded

    and also make sure you URL encod the status text. My first guess would be the URL encoding. If that does not work please try and capture the exact headers/body that you are sending (but be sure to obscure the Authoriztion header).

Thanks;
  — Matt Sanford (@mzsanford)

Scott Birksted

unread,
Dec 16, 2008, 3:28:30 PM12/16/08
to twitter-deve...@googlegroups.com


Ya this is very odd.

I set the request props in the header:
httpConn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
httpConn.setRequestProperty( "Content-Length", ""+encodedPostData.getBytes().length);

postData: status=testing
encodedPostData = c3RhdHVzPXRlc3Rpbmc=
encodedPostData len = 22

then write the encodedData to the output stream.

Checking the header details after that I see:
Content-Type : application/xml; charset=utf-8
Content-Length : 168

looks like some ghost in the (java) machine, I don't know why the headers seem incorrect and the content-length isn't being properly set.


<?xml version="1.0" encoding="UTF-8"?>
<hash>
  <request>/statuses/update.xml</request>
  <error>Client must provide a 'status' parameter with a value.</error>
</hash>
                              
-Scott

Matt Sanford

unread,
Dec 17, 2008, 10:26:35 AM12/17/08
to Twitter Development Talk
Hi Scott,

That encodedPostData data looks like Bas64 encoding. x-www-form-
urlencoded should be URL encoded only (which postData is, since it has
no spaces or other characters). As for the Content-Type and Content-
Length you're seeing, I believe those are the return headers and they
seem correct.

Thanks;
— Matt / @mzsanford

On Dec 16, 12:28 pm, "Scott Birksted" <out.in.the.str...@gmail.com>
wrote:
> Ya this is very odd.
>
> I set the request props in the header:
> httpConn.setRequestProperty("Content-Type","application/x-www-form-urlencod ed");
> httpConn.setRequestProperty( "Content-Length",
> ""+encodedPostData.getBytes().length);
>
> postData: status=testing
> encodedPostData = c3RhdHVzPXRlc3Rpbmc=
> encodedPostData len = 22
>
> then write the encodedData to the output stream.
>
> Checking the header details after that I see:
> Content-Type : application/xml; charset=utf-8
> Content-Length : 168
>
> looks like some ghost in the (java) machine, I don't know why the headers
> seem incorrect and the content-length isn't being properly set.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <hash>
>   <request>/statuses/update.xml</request>
>   <error>Client must provide a 'status' parameter with a value.</error>
> </hash>
>
> -Scott
>
Reply all
Reply to author
Forward
0 new messages