Here are explanations of various status codes you may receive on API responses.
200 - Success
The status code 200 means OK or Successfully your response is ready.
201 - Created
The status code 201 means your request has been created and you'll receive actual response in future responses that are caused by new requests
400 - Bad Request
Not Subscribed
Sometimes didn't subscribing to a service leads to this status code in a response, and you'll get an error message like this:
{
"message": "To access this service, you need to subscribe to this service from panel."
}
To Subscribe to a service, you should go to your MagicalAPI panel and do the following: (https://panel.magicalapi.com)
- Click on the services section, then select the service that you want to subscribe. (https://panel.magicalapi.com/services)
- finally, click on the subscribe button.
Invalid Request (JSON) Body
Another reason that may cause this status code, is sending a request with an invalid request body (JSON).
For example, if you forget a comma symbol, or do not close curly braces** etc, they lead to a response with this status code.
Here is an example response with this status code:
{
"message": "Your request is invalid. request body should be a valid json."
}
401 - Unauthorized
The status code 401 means you are not authorized correctly by api-key on request headers. there are different reasons the MagicalAPI API Gateway may send a response with this 401 status code:
- Forgetting to set api-key in the request's headers, and makes this response message:
{
"message": "Authentication Failed."
}
- If you set an invalid api-key also leads to 401 status code:
{
"message": "Unauthorized!"
}