How to resolve the "Invalid payload" error in API Integration

Learn how to resolve the Invalid payload error in API Integration.

Encountering errors is not uncommon in software development and API integration. A frequent issue is the “Invalid payload” error, often accompanied by a message like:

errorMessage: Invalid payload. Error: Unexpected character ('\<' (code 60)): expected a valid value

What causes the error

The core reason behind this issue is the mismatch between the expected data format and the actual data format received from the external service. When the connector expects JSON data but receives something else, such as XML, it fails to process the response correctly, leading to the Invalid payload error.

How to resolve the issue

Resolving the Invalid payload error involves addressing the mismatch between the expected and actual data formats. Here's a step-by-step guide to tackle this issue:

  1. Identify the source: Identify which endpoint or external service is returning the unexpected data format. This can often be determined by analyzing the error message and tracing it back to its source.

  2. Enable Advanced Mode: Open the settings of the connector that is returning the error and enable the Advanced Mode.

  3. Enable Raw Mode: After enabling Advanced Mode, enable the Raw Mode. This allows the connector to display the raw response from the external service.

  4. Save and deploy: Save the changes and deploy the new version of the connector. The next time the error occurs, the details will be displayed in the format sent by the external endpoint, making it easier to understand the error.

Conclusion

The Invalid payload error is a common obstacle in API integration, often due to discrepancies between the data formats of the connector and the external service. By understanding the underlying cause of the error and following the steps outlined above, you can effectively resolve this issue and ensure smooth communication between the application and external services.

Was this helpful?