Help parsing data - JSON Array -> Usable data?

Dear all,

My app makes a POST request which returns an array (see below)

Can someone please outline the returned data usable / avaliable in my app.
I have tried setting it to a page variable and then acsessing it - but to no avail.

Any help pointing me in the right direction would be much appreciated

please see below for the returned JSON info:

{
    [
            {
                "Messages": [
                    "1601408678079x920221217290013300",
                    "1601409759368x773841232542020500"
                ],
                "Users": [
                    "1601393507575x908413311360925400",
                    "1601389428885x735761663552804400"
                ],
                "Created By": "1601389595841x899319328381815900",
                "Created Date": 1601408208745,
                "Modified Date": 1601409759525,
                "UsernamesInChat": [
                    "anujn"
                ],
                "_id": "1601408208702x122071442214567660",
                "_type": "custom.chat"
            },
            {
                "Messages": [
                    "1601409786312x734845043664740500"
                ],
                "Users": [
                    "1601393507575x908413311360925400",
                    "1601389595841x899319328381815900"
                ],
                "Created By": "1601393507575x908413311360925400",
                "Created Date": 1601409585038,
                "Modified Date": 1601409786462,
                "UsernamesInChat": [
                    "anujn",
                    "tyler"
                ],
                "_id": "1601409585029x986849018880143400",
                "_type": "custom.chat"
            }
        ]
    
}

I think the best way would be to configure a Data resource for your API (see more info here: https://docs.appgyver.com/data/configuring-data-resources and https://docs.appgyver.com/data/rest-api-direct-integration). Then run the test and set resource schema based on that.

You could then use your data as Data variable instead of Page variable on the pages you wish. But if you want to use Page/App variables, make their schema match the Data resource schema exactly. Otherwise Composer won’t allow you to use direct bindings and will complain if you use Formulas.

Hey Tomi thanks for your reply.

The issue is that this is a POST request - so when it returns the array of objects - would I be able to use them like I would a GET (collection) request?

If not is there a workaround as for me to search the backend I am able to do much more complex search’s with post - otherwise I am left getting all of the data with GET - then would have to filter it client side - surely much slower

Yes, you should be able to use POST request response as you wish. If your API returns an array of same objects as Get record collection would, then you can use it as such. You decide yourself how to use the data.

When I am trying to do this - what is being returned is an object (with 8 properties). Not ‘a list of objects’.

Any suggestions?

I think finding the right Formulas that you can use and fit your use case is the correct way to go. LOOKUP() would probably be useful to you. If you have the data you need in the response, but in inconvenient schema, it’s just about parsing the data to the format and places you need to.

(If you’re familiar with Javascript, you can use Javascript Flow function and parse the data there programmatically. Still, Formulas will likely suit you well)

1 Like