Problem with setting get collection schema

Hi,

I have an issue with setting the response schema of a working API integration get record call. I get the following reply in the AppGyver UI:

Error: Error:
The result was not an array. Maybe the data you’re looking for is inside one of the response object keys?

{
“sys”: {
“type”: “Array”
},
“total”: 2,
“skip”: 0,
“limit”: 100,
“items”: [
{
“sys”: {
“id”: “6f95adpGN2o7SbWNbgMMB6”
}
},
{
“sys”: {
“id”: “lB8ONi4aKI9YioltljTJS”
}
}
]
}

How would I now proceed in setting up the schema? I’m interested in the Item[] array’s sys.id. This will be the ID I will use to call in a repeating component (Card) a data connector to get a specific data from the CMS.
eg. Card 1 content --> get data with ID 6f95adpGN2o7SbWNbgMMB6
Card 2 content --> get data with ID lB8ONi4aKI9YioltljTJS

and so on.

Unless there is another way of doing tihs with API’s?

In the Get Collection CONFIG tab, type “items” (without quotes) in the Response Key Path (of course, the Relative Path will already be filled in according to the Base settings).

Untitled

1 Like

Thanks @Nihal_Parkar this worked…

What does the response key path actually do? It somehow points the data to an array…?

Sorry that my question might seem stupid… I’m a newbie with API’s…

Different API’s embed information they return in different ways. In your test API call response, you can see that the response tells you in the first two lines that it is going to return items “sys” of type Array. Then it says “total”: 2, which is the number of items. Below total, after skip and limit, it says “items:” You can see that the items is the array (square brackets). Aha! That’s what you are looking for: it includes sys items with the id you are looking for. In other words, the Response Key Path (for this API) is “items”.

So you tell AppGyver that you are looking for “items” from the API response by noting that in the Response Key Path. As another example, the AirTable API response uses the term “records” to identify the array of items being returned.

So you can use this technique for any API. Of course, there may be APIs that just return the array of items without the initial information. In that case, the Response Key Path will be blank.

2 Likes

thanks alot Nihal for your help! This clarified things out quite a lot! :slight_smile:

1 Like