21Jun, 2017
0Comments

How To Update An External List Using Kizeo Forms’ API?

 

This article is intended for advanced Kizeo Forms users and the instructions given here require IT skills.

Using external lists inside your forms is very convenient. It allows you for instance to insert useful informations like customers contact details, lists of supplies or lists of references. You can re-use those same lists in different forms. Did you know that there is a way to automatically update all those lists? Meaning that when you make a change in the original list, it will be effective in the all the forms where you used this list. In order to do that, you need to use our API. Let’s see exactly how to proceed.

1. Make the inventory of all your external lists.

First of all, you need to retrieve the summary of all your external lists by using a GET request to the following URL: https://www.kizeoforms.com/lists/.

This first step will allow you to get an “id” of each one of your external lists linked to its name. This “id” will be necessary to continue.

You will retrieve the data doing as follows:

[
    {
        "id1": "Number_list_1",
        "name1": "Name_list_1"
    },
    {
        "id2": "Number_list_2",
        "name2": "Name_list_2"
    },
    {
        "id3": "Number_list_3",
        "name3": "Name_list_3"
    }
]

2. Retrieve all the items of your external lists.

The second step will be to retrieve the external list you want to update by using the “id” obtained when doing the GET request.

N.B.: To update them all, you need to do that for each one of your lists.

In order to have a full definition of it, without applying any filter when selecting its items, you need to send a GET request to the following URL: https://www.kizeoforms.com/lists/{listId}/complete. 

Be careful! When you send it, do not forget to insert your id token at the top of your request.

You should replace {listId} by the id of the list you want to update.

You will then receive your list under the following JSON format:

{
    "id": "integer",
    "name": "string",
    "items": [
        "Item1",
        "Item2",
        "Item3"
    ]
}

The “id” being the identifier of the list you asked for,  “name” being the name of this list and “items” being the table containing all the items as a string.

Just add to this list the items that you want to insert in your external list. Then, send once again a PUT request to the following URL: https://www.kizeoforms.com/lists/{listId}

Then add the list you just modified (will the old and new items) inside your request. You do not need to mention its id or name again.

For instance:

{
    "items": [
        "Item1",
        "Item2",
        "Item3",
        "New_item1",
        "New_item2"
    ]
}

Be careful: If you only send the new items in your PUT request, the old items will be deleted!

Feel free to comment this article!
We would be glad to hear any question, comment or suggestion you may have !

Post a comment

Your email address will not be published. Required fields are marked *