Discussions

 View Only
  • 1.  Restful API how to update multiple records?

    Posted 11-05-2021 13:52
    Hi,

    I'm new to QB and API. I'm trying to update a field (checkbox) in a table for multiple records using an unique Key field.
    I managed to update the field for one Key field, but failed to update multiple in one request.
    My script for one record looks like :
    {
    "to": "ID of my table",
    "data": [
    {
    "72": {
    "value": "unique Key field"
    },
    "60": {
    "value": true =>tick the checkbox
    }
    }
    ],
    "fieldsToReturn": [
    3
    ]
    }
    ​Is there a simple way to run this action with multiple values for my FiD 72?
    Thanks for your help.

    ------------------------------
    David NEGROBAR
    ------------------------------


  • 2.  RE: Restful API how to update multiple records?

    Posted 10-27-2023 04:08

    In documentation it says as multiple record(s). But Not able to do after trying with different syntax.



    ------------------------------
    Winss
    ------------------------------



  • 3.  RE: Restful API how to update multiple records?

    Posted 10-27-2023 08:56
    Edited by Doug Henning 10-27-2023 08:56

    The data parameter is an array of objects, with each object representing a record.  To update multiple records at once, just add additional record objects with the unique key value:

    {
        "to": "ID of my table",
        "data": [
            {
                "72": {
                    "value": "unique Key field 1"
                },
                "60": {
                    "value": true
                }
            },
            {
                "72": {
                    "value": "unique Key field 2"
                },
                "60": {
                    "value": true
                }
            }
        ],
        "fieldsToReturn": [
            3
        ]
    }

    Hope that helps!



    ------------------------------
    Doug Henning
    ------------------------------