Hello Everyone,
I would like to ask about JSON mapping to dynamic number of objects.
How this can be done? Any example/ resources?
As an example, we can use the following URL "https://jsonplaceholder.typicode.com/posts?userId=1" with the Postman with GET method, the response would be something similar to the following:
[ { "userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit" },
{
"userId": 1,
"id": 2,
"title": "qui est esse",
"body": "est rerum tempore vitae\nsequi sint "
}]
So, as you can see, there are multiple objects,. However, the error message I always get from PureCloud is:
{
"status": 400,
"code": "invalid.extraction.into.translation.map",
"message": "There was an issue extracting a value from the remote endpoint's response into the response translation map. Cause: Expected to find an object with property ['id'] in path $ but found 'java.util.ArrayList'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.",
"messageParams": {},
"contextId": "65e04558-8c48-43ef-b281-5b15e70e6f93",
"details": [],
"errors": []
}
On other hand, when I work only with single object, in which the response does not start with "[", it works successfully.
Please, any idea, or suggestion can be helpful.
Thank you,
------------------------------
Ali Aljohani
Jathwa Technology Solutions
------------------------------