Status Codes
This section provides an overview of the HTTP status codes used by the Smart Solar API, along with their meanings and possible causes.
HTTP Status Codes
The Smart Solar API uses standard HTTP status codes to indicate the success or failure of an API request. Below is a list of the most common status codes you may encounter when interacting with the API:
| Status Code | Meaning | Description |
|---|---|---|
| 200 | OK | The request was successful, and the server returned the requested data. |
| 201 | Created | The request was successful, and a new resource was created. |
| 204 | No Content | The request was successful, but there is no content to return (e.g., after a DELETE request). |
| 400 | Bad Request | The request was invalid or malformed. Check the request parameters and try again. |
| 401 | Unauthorized | Authentication failed. Ensure that you have provided a valid API key and access token. |
| 403 | Forbidden | You do not have permission to access the requested resource. Check your API key and access token. |
| 404 | Not Found | The requested resource could not be found. Check the endpoint URL and parameters. |
| 409 | Conflict | The request could not be completed due to a conflict with the current state of the resource (e.g., trying to create a resource that already exists). |
| 429 | Too Many Requests | You have exceeded the rate limit for API requests (see Rate Limiting section). |
| 500 | Internal Server Error | An unexpected error occurred on the server. Try again later. |
If you encounter an error status code, the response body may contain additional information about the error, including an error message and a code that can help you diagnose the issue. Always check the response body for more details when handling errors in your application.
Handling Errors
When making API requests, it's important to handle errors gracefully. Here are some best practices for error handling:
- Check Status Codes: Always check the HTTP status code of the response to determine if the request was successful or if an error occurred.
- Read Error Messages: If an error occurs, read the error message in the response body for more details about the issue.
- Retry Logic: Implement retry logic for transient errors (e.g., 500 Internal Server Error) to improve the resilience of your application.
- Rate Limiting: Be aware of rate limits and implement backoff strategies when you receive a 429 Too Many Requests response.
- Logging: Log errors for monitoring and debugging purposes, including the status code, error message, and any relevant request details.
For more information on specific error codes and their meanings, refer to the relevant sections of the API documentation.
Updated about 2 months ago
