Yes, the Java library throws an exception if the HTTP response code is
not 200. I guess it doesn't throw an exception the second time
because the HTTP response code is 200, because the note already
exists, because you created it the first time.
You can handle the exception, something like this:
try {
... oauthClient.invoke(...
} catch (OAuthProblemException e) {
int status = e.getHttpStatusCode();
if (200 <= status && status < 300) {
// Not really a problem.
} else {
throw e;
}
}
Should OAuthClient accept any 2xx response code without throwing an
exception? If so, I think it should also return the response code, so
the application can tell what happened. I guess that would be
implemented by making OAuthClient.invoke return an
OAuthResponseMessage, and adding a getHttpStatusCode() method to
OAuthResponseMessage.
On Jan 20, 1:33 am, Tane Piper <[email protected]> wrote:
> I'm adding some new features to my app - but have had some weird
> results recently. In my new feature, I use OAuth to post a note to
> the Brightkite service. I'm getting the exact same result each time
> here. When I open the activity and try to post, I have to do it
> twice, every time. And every time I get the exact same errors:
>
> [snip]
>
> The first one I have no idea why it's happening, but the second - I
> get a 201 created, which is a valid code - but the library still
> throws an exception. Does anyone have any ideas why it would do this,
> and how to handle it better? Is it possibly a bug in the library and
> it's only expecting a 200??
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"OAuth" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/oauth?hl=en
-~----------~----~----~----~------~----~------~--~---