Errors
Last updated
Last updated
When interacting with a web service, such as the Commerce API, it's crucial to interpret the feedback your requests receive. This feedback is communicated through HTTP response status codes, organized into several ranges, each representing a different type of response. Successfully executed requests return codes in the 2xx
range, indicating a successful operation. Errors caused by the client, such as missing parameters or processing issues, result in 4xx codes
. On the other hand, server-side errors produce 5xx
codes indicating problems with the server itself. An error code may sometimes accompany these HTTP status codes to explain the error concisely. Understanding these codes is essential for efficiently diagnosing and resolving issues with API requests.
See for information on the errors.
Understanding the basic principles of API interaction, such as recognizing HTTP status codes, is fundamental when working with web services like the Commerce API. However, diving into more nuanced aspects of API communication is imperative to build more resilient, efficient, and user-friendly applications.
The following tips can significantly improve your application's interaction with web services. Knowing and handling API rate limits and meticulously parsing error codes will prevent common pitfalls and enhance your application's overall reliability.
Inspect response headers: Beyond the status code, response headers can provide crucial contexts, like rate limits or deprecation warnings.
: Implementing a retry mechanism with exponential backoff for 5xx
server errors can improve the robustness of your application.
Leverage HTTP methods appropriately: Ensure you're using the correct HTTP method (GET, POST, PUT, DELETE) for the action you intend to perform, as this impacts both server response and behavior.
: Be aware of the API's rate limits to avoid hitting them, which would result in a 429 Too Many Requests
status code.
Parse error codes carefully: In addition to the HTTP status code, look at the API-specific error code (if available), which can offer more detailed insight into what went wrong.
Test with a REST client: Before integrating the API into your application, experiment with endpoints using a REST client to better understand the responses.
Contact support: If you encounter an API error that keeps occurring, you should create a case in the Solution Center. You can contact your CSM for more help or escalate the issue if necessary. In addition, if we log the error on our system, we may have monitoring set up to automatically create a case when a particular error occurs multiple times within a specific timeframe to help us investigate and address the issue promptly.
Understanding and applying these advanced tips can significantly enhance your interactions with web services and improve the reliability and efficiency of your API integrations.
While interacting with Shopper APIs, you might encounter situations where their actions only partially align with the expected requirements or constraints. Instead of outright failures, the API responds with warnings in such cases. These warnings serve as gentle alerts to the users that some aspects did not meet certain conditions or expectations while the server processed their request. Understanding and addressing these warnings can enhance the user experience by guiding adjustments to their requests to fully benefit from the services offered. The Warnings
object returned in the response plays a crucial role in this communication process, detailing the nature of the warning with a code and a description. This mechanism ensures that users are well-informed and can make necessary changes or decisions based on the feedback provided.
A warning is triggered when something unexpected occurs that is not severe enough to complete the request and implies that the request did not do what you intended. The warning will appear in the response. You can decide whether to continue with the checkout. For example, a shopper uses a product-restricted line item coupon code when the product is not in a cart or a shipping offer coupon code when the shipping method is unavailable for the cart or country.
A warnings
object should contain the following details: the code and description associated with the warning in a 200 OK
response.
The Shopper APIs use the following format for warnings:
When you receive a warning in the response from a Shopper API, it indicates that the request did not meet certain conditions when the system processed your request. Here's how you can address and resolve these warnings:
Review the warning: Carefully read the warning's code and description to understand the nature of the issue. The description will often provide insight into what was unexpected or why the request did not meet the criteria.
Adjust your request: Based on the warning's details, modify your request to align with the required conditions or expectations. It might involve changing parameters, adding necessary information, or removing conflicting elements.
Test and validate: After adjusting your request, test it to ensure the warning no longer appears and your request achieves the desired outcome.
Contact support: If you encounter an API error that keeps occurring, you should create a case in the Solution Center. You can contact your CSM for more help or escalate the issue if necessary. In addition, if we log the error on our system, we may have monitoring set up to automatically create a case when a particular error occurs multiple times within a specific timeframe to help us investigate and address the issue promptly.
Promptly resolving warnings ensures a smoother and more efficient integration with Shopper APIs, leading to a better overall experience.
The 200 OK
status code indicates that the system successfully processed the request. However, paying attention to any warnings that may accompany a successful response is important. These warnings notify you of issues that may not impact the immediate success of your request but could have implications for your application or user experience.
When interacting with web services or APIs, receiving a 200 OK status code is generally a sign that your request was successfully received, understood, and processed. However, it's essential to recognize that a 200 OK response might also come with errors or warnings. These are not outright failures but notifications or alerts about potential issues with your request. Understanding these 200 OK errors is crucial for diagnosing problems that might not interrupt your immediate operations but could affect long-term functionality or user experience. This section will delve into common errors and warnings associated with a 200 OK response, offering insights into their implications and how to address them.
inventory-unavailable-error
The product in the cart is unavailable because it is out of stock.
This section covers various warnings that you may see while using the system. While these warnings do not halt operations, they indicate conditions requiring adjustments or further attention to ensure optimal functionality. These notifications might include eligibility issues with coupon codes, inventory alerts, or tax-related advisories. Understanding and addressing these warnings can enhance your experience and interaction with the platform.
couponcode_not_elegible
The applicable discount triggered by the provided coupon code will be applied to the cart once it meets the offer criteria. The shopper must add the item associated with the coupon code associated to the cart.
tax_service_invalid_hsCode_warning
To calculate landed cost, you must provide the correct HS code when creating a product. When you send an incorrect HS code to the landed cost calculator, Digital River can calculate the importTax, but the importDuty might not be available.
Refer to documentation: Consult the documentation for more information on the warning codes and suggested actions. The documentation often provides examples and guidelines that can help resolve the warning.