Handling API Errors
When the request cannot be sent
It means that it did not reach the destination API server. This can happen for several reasons:
- Incorrect configuration in Wized: Carefully review your request configuration in the Requests panel. Make sure the endpoint URL, HTTP method (GET, POST, etc.), headers, and body are correct and match the API requirements.
- API service is temporarily down: Sometimes the API server may be experiencing technical issues or undergoing maintenance. In this case, the request will not be able to reach its destination.
- The API does not accept direct requests from the browser: Some APIs are configured to accept requests only from servers, not directly from the user's browser. Wized, by default, sends requests from the browser, which can cause problems in these cases. Use secrets to send your REST requests through our servers to avoid this problem.
How to investigate if the request is not sent?
- Check the Logs Dashboard and Data Store: If the request is not sent, you will usually see a 500 error code and a description like "failed to fetch" in the "States" tab of the request in the Data Store Dashboard. This indicates that the request did not reach the API server.
- Check your request configuration: Carefully review the endpoint URL, HTTP method, headers, and body in the Requests Dashboard. Make sure they match the API documentation.
- Check the API service status: If you suspect the problem is with the API server, visit the provider's website or search online for information about the service status.
- Consider using Secrets or Native Integrations: If the API doesn't accept direct requests from the browser, you can use the "Secrets" feature in Wized to send the request through our servers. You can also check if Wized offers a native integration with the service you're using, as these integrations usually handle communication with the API more securely and efficiently.
If the request returns an error
If the request reaches the API server but the API encounters a problem, it will respond with an HTTP error code. These codes are standardized messages that indicate the type of problem encountered. Some of the most common ones are:
- 400 Bad Request: The request is poorly formatted or missing required data.
- 401 Unauthorized: You need to provide valid authentication credentials.
- 403 Forbidden: You do not have permission to access the requested resource.
- 404 Not Found: The resource you are looking for does not exist.
- 500 Internal Server Error: There is a problem with the API server.
How to investigate
- Check the HTTP status code: In the "Statuses" tab of the request in the Data Store Panel, you will find the HTTP status code of the response. Look up its meaning online to understand the type of error.
- Examine the response body: Many APIs provide detailed error messages within the response body (in the "Body" tab of the Data Store Panel). These messages will give you more specific information about the problem.
- Check the API documentation: The API documentation will help you interpret the error codes and specific messages you receive, and offer solutions or steps to take to resolve the issue.
Troubleshooting Tools
Your best ally for troubleshooting API issues in Wized is the Data Store Panel . Here you can:
- View the request status: Check whether the request was executed successfully ( hasRequested and isRequesting ), whether there was an error ( ok ), and the HTTP status code ( status ).
- Inspect the response: Examine the headers and body of the response for details about the error or information returned by the API.
- Compare with documentation: Consult the API documentation to understand the structure of the expected response and possible error codes.
Difference between HTTP error codes and errors in the Body
- HTTP Status Codes: These are numeric responses sent by the API server that indicate the overall outcome of the request (success, error, redirect, etc.). You can find a list of HTTP status codes here
- Errors in the Body: Some APIs, even when returning a 200 (OK) status code, may include detailed error messages within the response body (in the "Body" tab of the Data Store Panel). These messages will give you more specific information about the problem.