This site has been archived. Please visit help.fulcrumapp.com for our new support documentation and contact information.

Delete repeatable record through API

greig.dendor's Avatar

greig.dendor

28 Jul, 2014 09:59 AM

Hello,

How can I delete a record within a repeatable using the API?

Thanks
Greig Dendor

  1. 1 Posted by greig.dendor on 30 Jul, 2014 06:38 AM

    greig.dendor's Avatar

    Hello - I don't seem to have had a response to my question, I'm hoping this comment will alert someone!

    Thanks
    Greig

  2. 2 Posted by Kyle Tolle on 30 Jul, 2014 04:51 PM

    Kyle Tolle's Avatar

    Hi Greig,

    I was already digging into this by the time you send that second message.

    To update a record, one must PUT to the /api/v2/records/<RECORD_ID> endpoint. Remember to set the Content-Type: application/json HTTP header.

    Removing an item from within a repeatable is as easy as removing that specific repeatable item from the repeatable items array within the JSON and then PUTing that updated JSON to the API.

    For example, let's say we started with this record:

    {
        "record": {
            "altitude": null,
            "assigned_to": null,
            "assigned_to_id": null,
            "client_created_at": "2014-07-30T15:51:47Z",
            "client_updated_at": "2014-07-30T15:51:47Z",
            "course": null,
            "created_at": "2014-07-30T15:51:47Z",
            "created_by": "Kyle Tolle",
            "created_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
            "form_id": "04160c58-c64c-46d0-945d-4fa65d730603",
            "form_values": {
                "1fa4": "Canadian English",
                "b20b": [
                    {
                        "created_at": "1406735489",
                        "created_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
                        "form_values": {
                            "8d25": "A"
                        },
                        "geometry": null,
                        "id": "123df183-dcb8-ed0e-f1d8-ccf07a5ea8c2",
                        "updated_at": "1406735489",
                        "updated_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
                        "version": 1
                    },
                    {
                        "created_at": "1406735492",
                        "created_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
                        "form_values": {
                            "8d25": "B"
                        },
                        "geometry": null,
                        "id": "e1a00cad-0776-913f-83f3-8c92e61c1bcd",
                        "updated_at": "1406735492",
                        "updated_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
                        "version": 1
                    },
                    {
                        "created_at": "1406735495",
                        "created_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
                        "form_values": {
                            "8d25": "AA"
                        },
                        "geometry": null,
                        "id": "a3d675d6-2dc4-d41f-0581-1806c5cf6321",
                        "updated_at": "1406735495",
                        "updated_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
                        "version": 1
                    }
                ]
            },
            "horizontal_accuracy": null,
            "id": "541c7aee-956f-4f3d-b800-233912293056",
            "latitude": 55.4290134524074,
            "longitude": -105.9521484375,
            "project_id": null,
            "speed": null,
            "status": null,
            "updated_at": "2014-07-30T15:51:47Z",
            "updated_by": "Kyle Tolle",
            "updated_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
            "version": 1,
            "vertical_accuracy": null
        }
    }
    

    And we want to remove the repeatable item with the value "AA".

    We can just remove that object from the JSON and then post the modified JSON back to the API:

    {
        "record": {
            "altitude": null,
            "assigned_to": null,
            "assigned_to_id": null,
            "client_created_at": "2014-07-30T15:51:47Z",
            "client_updated_at": "2014-07-30T15:51:47Z",
            "course": null,
            "created_at": "2014-07-30T15:51:47Z",
            "created_by": "Kyle Tolle",
            "created_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
            "form_id": "04160c58-c64c-46d0-945d-4fa65d730603",
            "form_values": {
                "1fa4": "Canadian English",
                "b20b": [
                    {
                        "created_at": "1406735489",
                        "created_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
                        "form_values": {
                            "8d25": "A"
                        },
                        "geometry": null,
                        "id": "123df183-dcb8-ed0e-f1d8-ccf07a5ea8c2",
                        "updated_at": "1406735489",
                        "updated_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
                        "version": 1
                    },
                    {
                        "created_at": "1406735492",
                        "created_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
                        "form_values": {
                            "8d25": "B"
                        },
                        "geometry": null,
                        "id": "e1a00cad-0776-913f-83f3-8c92e61c1bcd",
                        "updated_at": "1406735492",
                        "updated_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
                        "version": 1
                    }
                ]
            },
            "horizontal_accuracy": null,
            "id": "541c7aee-956f-4f3d-b800-233912293056",
            "latitude": 55.4290134524074,
            "longitude": -105.9521484375,
            "project_id": null,
            "speed": null,
            "status": null,
            "updated_at": "2014-07-30T15:51:47Z",
            "updated_by": "Kyle Tolle",
            "updated_by_id": "d103dc89-28e2-47c6-88c0-9f57c6a5561b",
            "version": 1,
            "vertical_accuracy": null
        }
    }
    

    Using curl, the entire request would look something like this:

    curl -H "X-ApiToken: bbc5f8723790fb54482fdbcfadf39adfddde13ca76f7540a518deed4fae22797"
    -H "Content-Type: application/json"
    -X PUT
    https://api.fulcrumapp.com/api/v2/records/541c7aee-956f-4f3d-b800-233912293056
    --data '{"record":{"altitude":null, "assigned_to":null, "assigned_to_id":null, "client_created_at":"2014-07-30T15:51:47Z", "client_updated_at":"2014-07-30T15:51:47Z", "course":null, "created_at":"2014-07-30T15:51:47Z", "created_by":"Kyle Tolle", "created_by_id":"d103dc89-28e2-47c6-88c0-9f57c6a5561b", "form_id":"04160c58-c64c-46d0-945d-4fa65d730603", "form_values": {"1fa4":"Canadian English", "b20b": [{"created_at":"1406735489", "created_by_id":"d103dc89-28e2-47c6-88c0-9f57c6a5561b", "form_values":{"8d25":"A"}, "geometry":null, "id":"123df183-dcb8-ed0e-f1d8-ccf07a5ea8c2", "updated_at":"1406735489", "updated_by_id":"d103dc89-28e2-47c6-88c0-9f57c6a5561b", "version":1}, {"created_at":"1406735492"," created_by_id":"d103dc89-28e2-47c6-88c0-9f57c6a5561b", "form_values":{"8d25":"B"}, "geometry":null, "id":"e1a00cad-0776-913f-83f3-8c92e61c1bcd", "updated_at":"1406735492", "updated_by_id":"d103dc89-28e2-47c6-88c0-9f57c6a5561b", "version":1}]}, "horizontal_accuracy":null, "id":"541c7aee-956f-4f3d-b800-233912293056", "latitude":55.4290134524074, "longitude":-105.9521484375, "project_id":null, "speed":null, "status":null, "updated_at":"2014-07-30T15:51:47Z", "updated_by":"Kyle Tolle", "updated_by_id":"d103dc89-28e2-47c6-88c0-9f57c6a5561b", "version":1, "vertical_accuracy":null}}'
    

    Let us know if you have any further questions.

    Cheers,
    Kyle

  3. 3 Posted by greig.dendor on 31 Jul, 2014 09:58 AM

    greig.dendor's Avatar

    Hi Kyle, that answers my question thank you.

    Greig

    Greig Dendor
    Associate Director
     

    Oxhey Hall Consulting Ltd
    The Wenta Business Centre,
    Colne Way, Watford, WD24 7ND
    m: 07539 255540
    e: [email blocked]
    www.oxheyhall.com
     

     
     
    This communication contains information which is confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any distribution, copying or use of this communication or the information in it is strictly prohibited. If they have come to you in error, then we apologise. Please take no action based on them, nor copy or show them to anyone else; please reply to this e-mail and highlight the error.
    Security Warning: Please note that this e-mail has been created in the knowledge that Internet e-mail is not a 100% secure communications medium. We advise that you understand and observe this lack of security when e-mailing us.
    Viruses: Although we have taken steps to ensure that this e-mail and attachments are free from any virus, we advise that in keeping with good computing practice the recipient should ensure they are actually virus free.
    Please consider the environment before printing this e-mail

  4. Kyle Tolle closed this discussion on 31 Jul, 2014 07:58 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac