Change in error response objects

156 views
Skip to first unread message

Marc Mims

unread,
Aug 27, 2010, 12:33:04 AM8/27/10
to Twitter Development Talk
It looks like error responses have changed, at least for users/show.

I used to get:
{"error":"User has been suspended"}

Now, I get:
{"errors":[{"code":63,"message":"User has been suspended"}]}

Other methods still return the old format, e.g., statuses/show. I get:
{"request":"/1/statuses/show/123456789012345.json","error":"No status found with that ID."}


Was this change announced? Will all methods now return an array of
errors? Is there a documented list of error codes?

-Marc

Cameron Kaiser

unread,
Aug 27, 2010, 7:45:40 AM8/27/10
to twitter-deve...@googlegroups.com
> It looks like error responses have changed, at least for users/show.
>
> I used to get:
> {"error":"User has been suspended"}
>
> Now, I get:
> {"errors":[{"code":63,"message":"User has been suspended"}]}

I'm seeing that too. When did this change?

--
------------------------------------ personal: http://www.cameronkaiser.com/ --
Cameron Kaiser * Floodgap Systems * www.floodgap.com * cka...@floodgap.com
-- They told me I was gullible ... and I believed them. -----------------------

Raffi Krikorian

unread,
Aug 27, 2010, 9:03:07 AM8/27/10
to twitter-deve...@googlegroups.com
hi all.  

this is most certainly a mistake on our part - we'll be reverting this change. 


--
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: http://groups.google.com/group/twitter-development-talk?hl=en



--
Raffi Krikorian
Twitter Platform Team
http://twitter.com/raffi


Marc Mims

unread,
Aug 27, 2010, 9:32:54 AM8/27/10
to twitter-deve...@googlegroups.com
* Raffi Krikorian <ra...@twitter.com> [100827 06:03]:

> this is most certainly a mistake on our part - we'll be reverting this
> change.

The new error format looks useful, especially if the error code allows
us to deal with multi-lingual error messages consistently. Obviously,
some advanced notice and consistency across the API will be helpful.

I'm still very interested in seeing Twitter provide library developers
with advanced notice under non-disclosure for changes like this.

-Marc

Raffi Krikorian

unread,
Aug 27, 2010, 9:54:00 AM8/27/10
to twitter-deve...@googlegroups.com
All newer API methods have been returning API error codes for a while
now. We have been extremely sensitive to not breaking older behavior
(for backwards compatbility reasons), so older methods still return
the old format. We have been toying with the ability to get error
codes on all methods if developers pass in a special parameter, or
header, but we haven't gotten very far down that route yet.

Marc Mims

unread,
Aug 27, 2010, 10:15:01 AM8/27/10
to twitter-deve...@googlegroups.com
* Raffi Krikorian <ra...@twitter.com> [100827 06:54]:

> All newer API methods have been returning API error codes for a while
> now. We have been extremely sensitive to not breaking older behavior
> (for backwards compatbility reasons), so older methods still return
> the old format. We have been toying with the ability to get error
> codes on all methods if developers pass in a special parameter, or
> header, but we haven't gotten very far down that route yet.

Is there documentation for the error codes and format of error responses
for those newer methods? Which methods support error codes in error
responses?

-Marc

Marc Mims

unread,
Aug 29, 2010, 12:00:12 PM8/29/10
to twitter-deve...@googlegroups.com
* Raffi Krikorian <ra...@twitter.com> [100827 06:03]:

> hi all.
>
> this is most certainly a mistake on our part - we'll be reverting this
> change.

Raffi, we're still seeing these unexpected error structures. When will
the change be reverted?

-Marc

Dewald Pretorius

unread,
Aug 29, 2010, 7:25:03 PM8/29/10
to Twitter Development Talk
Raffi,

Will the new error construct always be:

[errors][code]
[errors][message]

Or can it be sometimes:

[errors][0][code]
[errors][0][message]
[errors][1][code]
[errors][1][message]

Raffi Krikorian

unread,
Aug 30, 2010, 8:47:49 AM8/30/10
to twitter-deve...@googlegroups.com
what endpoints are you still seeing this error format under?  the change should have been reverted in the case that you were mentioning.

--
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: http://groups.google.com/group/twitter-development-talk?hl=en

Raffi Krikorian

unread,
Aug 30, 2010, 8:48:23 AM8/30/10
to twitter-deve...@googlegroups.com
it is designed so that we can send multiple error codes back, but in practice, right now, we only send one.


--
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: http://groups.google.com/group/twitter-development-talk?hl=en

Cameron Kaiser

unread,
Aug 30, 2010, 8:52:39 AM8/30/10
to twitter-deve...@googlegroups.com
> what endpoints are you still seeing this error format under? the change
> should have been reverted in the case that you were mentioning.

TTYtter> /set superverbose 1
TTYtter> /whois [xxx]
[...]
url = "https://api.twitter.com/1/users/show.json?screen_name=[xxx]"


{'errors':[{'code':63,'message':'User has been suspended'}]}
TTYtter>

--
------------------------------------ personal: http://www.cameronkaiser.com/ --
Cameron Kaiser * Floodgap Systems * www.floodgap.com * cka...@floodgap.com

-- This message will self-destruct in five seconds. Good luck, Jim. -- M:I ----

Mike Francisco

unread,
Aug 30, 2010, 10:42:14 AM8/30/10
to Twitter Development Talk, mike.c.f...@gmail.com

Marc Mims

unread,
Aug 30, 2010, 11:42:59 AM8/30/10
to twitter-deve...@googlegroups.com
* Raffi Krikorian <ra...@twitter.com> [100830 05:48]:

> what endpoints are you still seeing this error format under? the change
> should have been reverted in the case that you were mentioning.

Like Cameron, I'm seeing it on users/show. Here's an example:
GET http://api.twitter.com/1/users/show/178618878.json

{"errors":[{"code":63,"message":"User has been suspended"}]}

-Marc

Marc Mims

unread,
Sep 1, 2010, 2:07:48 AM9/1/10
to twitter-deve...@googlegroups.com
I'm seeing these error responses on other endpoints, now.

Here's the result of an OAuth authenticated request for friends_ids:
{"errors":[{"code":53,"message":"Basic authentication is not supported"}]}

Then verify_credentials Authenticating as the same user:
{"request":"/1/account/verify_credentials.json","error":"Could not authenticate with OAuth."}

Then an unauthenticated users/show for the same user:


{"errors":[{"code":63,"message":"User has been suspended"}]}

So, I finally see what the real problem is. The inconsistency in error
formats and messages is quite difficult to deal with.

I'm also getting these errors for friends_ids. Interestingly, this is
the response I get using OAuth.


* Raffi Krikorian <ra...@twitter.com> [100830 05:48]:

MrMoxy

unread,
Sep 3, 2010, 12:35:30 PM9/3/10
to Twitter Development Talk
Raffi,

I have been using the API to tweet twice daily for months, but my
script suddenly stopped working yesterday morning. I am posting to
this page using a curl connection

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

and it keeps returning a 401 error. I have verified that my username &
password have not changed. Does the error have something to do with
the changes you made? How can I fix this?

Thanks!

Steve
SEJohnsen at gmail.com

$mypost=$data['post'];
$twitter_user = "user";
$twitter_password = "pwd";
$twitter_api_url = "http://twitter.com/statuses/update.xml";
$twitter_data = "status=".$mypost;

$ch = curl_init($twitter_api_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $twitter_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "{$twitter_user}:
{$twitter_password}");

$twitter_data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);


On Aug 27, 7:03 am, Raffi Krikorian <ra...@twitter.com> wrote:
> hi all.
>
> this is most certainly a mistake on our part - we'll be reverting this
> change.
>
> On Fri, Aug 27, 2010 at 4:45 AM, Cameron Kaiser <spec...@floodgap.com>wrote:
>
> > > It looks like error responses have changed, at least for users/show.
>
> > > I used to get:
> > > {"error":"User has been suspended"}
>
> > > Now, I get:
> > > {"errors":[{"code":63,"message":"User has been suspended"}]}
>
> > I'm seeing that too. When did this change?
>
> > --
> > ------------------------------------ personal:
> >http://www.cameronkaiser.com/--
> >  Cameron Kaiser * Floodgap Systems *www.floodgap.com*
> > ckai...@floodgap.com

Tom van der Woerdt

unread,
Sep 3, 2010, 12:42:21 PM9/3/10
to twitter-deve...@googlegroups.com

Matt Harris

unread,
Sep 3, 2010, 1:03:52 PM9/3/10
to twitter-deve...@googlegroups.com
Hey Steve,

To expand on Tom's message, Basic Auth is no longer supported on the
Twitter API and you need to update your script to use OAuth. In
addition you want to make sure the URL you are calling is pointing to
http://api.twitter.com/1/statuses/update.xml - all API requests should
go through http://api.twitter.com now.

Information about transitioning from basic to OAuth is here:
http://dev.twitter.com/pages/basic_to_oauth

There are community libraries available which may be of help:
http://dev.twitter.com/pages/oauth_libraries

Hope that explains why your script stopped working and what you can do
to get it working again.
Matt

--


Matt Harris
Developer Advocate, Twitter
http://twitter.com/themattharris

Steve Johnsen

unread,
Sep 3, 2010, 12:59:02 PM9/3/10
to twitter-deve...@googlegroups.com
Tom,

Thanks! That helps a lot.

Now I just have to figure out how to use it!

Steve

Steve Johnsen

unread,
Sep 3, 2010, 1:43:30 PM9/3/10
to twitter-deve...@googlegroups.com
Matt,

Thank you very much!

Steve

-----Original Message-----
From: twitter-deve...@googlegroups.com
[mailto:twitter-deve...@googlegroups.com] On Behalf Of Matt Harris
Sent: Friday, September 03, 2010 11:04 AM
To: twitter-deve...@googlegroups.com
Subject: Re: [twitter-dev] Re: Change in error response objects

Steve Johnsen

unread,
Sep 3, 2010, 7:15:26 PM9/3/10
to twitter-deve...@googlegroups.com
Thanks to all for the pointers. I got everything rewritten and working now
thanks to the examples from Joe Chung.

http://nullinfo.wordpress.com/oauth-twitter/

Steve

Reply all
Reply to author
Forward
0 new messages