Define json parameters in api

Hello,

Can you please help me to figure out how should I set up parameter fields of an API method so it will accept this kind of JSON?

{
    "deltas": [
        {
            "date": 1647532662,
            "object": "event",
            "type": "event.created",
            "object_data": {
                "namespace_id": "cct42fracyj4lv77loz8n3pd9",
                "account_id": "cct42fracyj4lv77loz8n3pd9",
                "object": "event",
                "attributes": {
                    "created_before_account_connection": true,
                    "calendar_id": 31243722414895696
                },
                "id": "2ymvp6oqys6dqnilamlgly62j",
                "metadata": {
                    "event-type": "Silver invoice",
                    "message": "Hello Silver"
                }
            }
        }
    ]

}

Hello @Mikhail

If you set up your Codeless API service with one parameter “deltas” that should look like

image

And will accept an array of objects as below

[
        {
            "date": 1647532662,
            "object": "event",
            "type": "event.created",
            "object_data": {
                "namespace_id": "cct42fracyj4lv77loz8n3pd9",
                "account_id": "cct42fracyj4lv77loz8n3pd9",
                "object": "event",
                "attributes": {
                    "created_before_account_connection": true,
                    "calendar_id": 31243722414895696
                },
                "id": "2ymvp6oqys6dqnilamlgly62j",
                "metadata": {
                    "event-type": "Silver invoice",
                    "message": "Hello Silver"
                }
            }
        }
    ]

But if you want to set up completely the same schema as you described - just add one not required “stub” parameter, and just ignore it in the code.

image

After that service will accept JSON that you provided.

Regards, Dima.

1 Like

How can I use it to make https calls?
I need to pass values account_id and id, can’t figure it out. I’m using call with STUB

STUB it’s just an empty argument, you don’t need to use it. As I said before: “just ignore it in the code.”

I need to pass values account_id and id, can’t figure it out

If I understand correctly, this values should be in deltas argument.

1 Like

I was able to get the values by striping the JSON untill it start to look normal.
Can you help me, what should I read to understand this object logic, I’m sure it’s usual code stuff, but I struggle a lit bit with the concept.

You could watch this - Navigating Object Hierarchy in Codeless Programming - YouTube

Also, you will be able to find a lot of information here, but it could struggle you because it’s developer’s documentation.

1 Like