Troubleshooting REST data sources
Prerequisite
- Access to the Data source management > Data sources > REST (DI001) menu.
Introduction
This article presents suggestions and solutions to the most common problems in case you are faced with any hindrances while using our REST data sources.
See, in the following sections, the issues you may find after inserting the request/response body or during the consumption test, along with their possible solutions:
Problems when inserting the request/response body
During the Input parameters and Output parameters data source steps, when inserting an example request/response body, one of the cases below may occur, thus preventing the user from moving forward to the next step:
The "Parameter ID #" array entered in the example should contain only one item and this must be a JSON object
This problem occurs when the JSON added to the example body contains an attribute of the array type, but said attribute has more than one element and/or its type is not object.
Within the REST data source, only arrays containing an object are recognized, since the inserted example will be used to set the attributes.
Invalid example:
{
"request": [1, 2, 3, 4],
"request2": [
{
"id": 0
},
{
"id": 0
}
]
}
Valid example:
{
"request": [
{
"id": 0
}
]
}
In the invalid example, both attributes (request and request2) are not valid for the component.
The data source uses the attributes from a single specified object to read the attributes. Thus, there can only be one object in the list.
If your example request/response body contains more than one object, simply leave only one of them within the list structure. Otherwise, if there are elements that are not objects, they will not be supported by the REST data source.
It has not been possible to identify the "Parameter ID #" parameter type. Please enter a valid value so that it is possible to identify the data type.
This problem occurs when an attribute from the request/response body JSON has a null value.
Since the data source uses the added JSON to map the necessary attributes in order to consume the data, a null type cannot be identified by the component, as it needs a clearly defined type.
Invalid example:
{
"request": null
}
Valid example:
{
"request": 1000
}
To solve this problem, simply define the correct type for the specified attribute. If you do not know the type of the attribute to be applied, check it in the specification of the service to be integrated.
In the valid example, the attribute type will be identified as numeric. For the attribute value, add a value that corresponds to the desired type for the integrated service.
The object "Parameter ID #" must have at least one lower level
This problem occurs when, in the request/response body JSON, there is an attribute that is a JSON object, but said object does not have any children associated. Thus, the component cannot interpret the attribute.
Invalid example:
{
"“request": [
"r1" : {}
]
}"
Valid example:
{
"request":[
"r1":{
"id":90,
"name":"test"
}
]
In the invalid example, the JSON will not be correctly interpreted by the component, since the r1 attribute is an object without children associated.
To solve the problem, the children of the attribute with this problem must be mapped correctly. This information must be checked in the specification of the service to be integrated.
Problems when consuming a source during the consumption test
Unable to build the request/response body for the data source
This problem may occur due to any of the following situations:
- Incorrect mapping of the request/response body in the data source: check if the attributes mapped in the request/response body are in accordance with the service to be consumed.
- PATH-type parameters have been declared, but not all of them have been completed: fill out all PATH-type parameters before consuming the source.
Could not execute the service from the data source: java.net.ConnectException: Connection refused (Connection refused)
It could mean that the host and the port of the specified service (in the URL passed during the REST service data step) are not being found when the service is consumed. Check if the declared URL is valid for consumption.
Could not execute the service from the data source: java.net.UnknowHostException
When trying to consume the service, the source cannot find the service host. Check if the URL domain is a valid domain.
HTTP Code
If any of the HTTP statuses is returned as a response when consuming the service, check the following chart for the returned status:
-
401 (HTTP 401 Unauthorized)
◦The service requires an authentication to be consumed. Check if the data source has authentication and if it is correct. -
403 (HTTP 403 Forbidden)
◦The specified service does not allow for accessing the requested resource. -
500 (HTTP 500 Internal Server Error)
◦An unexpected error has occurred in the resource to be consumed.
Conclusion
All done! Now you know possible solutions in case you are faced with problems while using REST data sources.