Skip to main content

Error Handling for API access

To identify the cause of an error when accessing the API, the Mobage Open Platform RESTful API returns error information in JSON format in addition to the response code.

HTTP Response Status Codes​

The Mobage Open Platform RESTful API handles the following HTTP status codes.

Response codeResponse messageDescription
200OKProcessing was successful
201CreatedNew resource was created successfully
202AcceptedRequest was accepted normally
400Bad RequestRequest data contains an invalid value
401UnauthorizedOAuth authorization failed
404Not FoundResource does not exist
405Method Not AllowedMethod is not allowed
500Internal Server ErrorProcessing failed because of an API problem
503Service UnavailableAPI cannot be accessed temporarily

For more information, please see OpenSocial RESTful Protocol Specification v0.9 - 13. HTTP Status Codes .

HTTP Response when an Error Occurs​

When an error occurs, error information is returned in JSON format. See the examples below.

The TextData API is used to get a list of TextDataGroup collections in Proxy mode​

Request​

GET http://sb.sp.app.mbga.jp/api/restful/v1/textdata/@app/@all?format=json
Accept-Encoding: gzip
Authorization: OAuth realm="", oauth_consumer_key="XXXXXXXXXX", oauth_nonce="YYYYYYYY", oauth_signature="ZZZZZZZZZ", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1262688790", oauth_token="AAAAAAAAA", oauth_version="1.0", xoauth_requestor_id="100"
User-Agent: OAuth::Lite::Consumer/1.22

Response​

By looking at the Message value, it is apparent that this API access cannot be performed in Proxy mode.

405 Method Not Allowed
Connection: close
Date: Tue, 05 Jan 2010 10:53:10 GMT
Server: lighttpd/1.4.22
Content-Length: 61
Content-Type: application/json
Client-Date: Tue, 05 Jan 2010 10:53:10 GMT

{"Error": {"Message":" Proxy Request is not allowed this API"}}

When Access is Attempted with an Invalid consumer_key​

Request​

GET http://sb.sp.app.mbga.jp/api/restful/v1/people/@me/@self?format=json
Accept-Encoding: gzip
Authorization: OAuth realm="", oauth_consumer_key="BadConsumerKey", oauth_nonce="XXXXXXX", oauth_signature="YYYYYYYY", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1262689167", oauth_token="ZZZZZZZZZZZ", oauth_version="1.0", xoauth_requestor_id="100"
User-Agent: OAuth::Lite::Consumer/1.22

Response​

When the id and consumer_key pair of a given application do not match, the following gives an example of the error message that is returned.

401 Unauthorized
Connection: close
Date: Tue, 05 Jan 2010 11:03:58 GMT
Server: lighttpd/1.4.22
Content-Length: 133
Content-Type: application/json
Client-Date: Tue, 05 Jan 2010 11:03:58 GMT

{"Error": {"Message":" wrong consumer infomation ( no exists consumer info [app_id: 12300000, consumer_key: BadConsumerKey] )"}}

Notes​

  • Use only HTTP status codes when handling errors in a program. Error messages that are returned in JSON format may change without prior notice. Use these error messages to resolve problems during development.

OpenSocial RESTful Protocol Specification v0.9 - 13. HTTP Status Codes

Revision History​

  • 12/11/2012
    • Initial release
  • HTTP Response Status Codes
  • HTTP Response when an Error Occurs
    • The TextData API is used to get a list of TextDataGroup collections in Proxy mode
    • When Access is Attempted with an Invalid consumer_key
    • Notes
  • Reference Links
  • Revision History