How to save, edit and post API responses from Bubble?

60 Views Asked by At

I'm just learning Bubble and I have some difficulties that I encountered. The problem is that I need to receive data, process it and send it back. At the same time, extract certain values of their response into JSON.

Example:

{
    "cards": [
        {
            "nmID": 12383295,
            "imtID": 9297853,
            "nmUUID": "018c08a7-5d05-7a9c-9423-80e599047ab8",
            "subjectID": 3137,
            "subjectName": "Урбеч",
            "vendorCode": "nao-5nao-5",
            "brand": "",
            "title": "Title",
            "description": "Some description here",
            "dimensions": {
                "length": 9,
                "width": 9,
                "height": 11
            },
            "sizes": [
                {
                    "chrtID": 38470141,
                    "techSize": "0",
                    "wbSize": "",
                    "skus": [
                        "4626015349130"
                    ]
                }
            ],
            "createdAt": "2020-05-13T01:46:46Z",
            "updatedAt": "2024-02-24T12:41:16.4192Z"
        },
        {
            "nmID": 212400431,
            "imtID": 191822480,
            "nmUUID": "018ddabe-fec7-7476-8dac-05138b28488b",
            "subjectID": 192,
            "subjectName": "Polo",
            "vendorCode": "test",
            "brand": "Brand",
            "title": "Polo",
            "description": "Description here",
            "dimensions": {
                "length": 20,
                "width": 25,
                "height": 21
            },
            "sizes": [
                {
                    "chrtID": 339615565,
                    "techSize": "XL",
                    "wbSize": "52",
                    "skus": [
                        "2039558028783"
                    ]
                }
            ],
            "createdAt": "2024-02-24T10:52:46.832077Z",
            "updatedAt": "2024-02-24T10:52:46.832077Z"
        },
        {
            "nmID": 10617728,
            "imtID": 163219155,
            "nmUUID": "018c08ac-0b85-7c10-85a0-58c2b61dbf7c",

So I need to find in the response the data of one card containing the value nmID 12383295. Change "description": "Some text here" to the value from the variable and send back.

Help me with advice, how to do this in Bubble.

I receive a list of products upon request via API. I need to find the one I need. For example, with nmID 12383295. Change its description.

enter image description here

1

There are 1 best solutions below

0
Rachael On BEST ANSWER

Yeah, I can see how that would be tricky. So, I recommend setting up your API call with the API Connector plugin (GET to receive data), and include headers and parameters

If you wan tto display the received API data in your app, put it in a repeating group

To locate a specific item by nmID, apply Bubble's :filtered operator, matching the target nmID (12383295)

To change an item's description, trigger a workflow with something like a button click. Use the "make changes to a thing" action to update the description

To send the modified data back, configure a POST API call using the API Connector, with the updated data in the request body

You can use Toolbox plugin for custom JavaScript if you need to.

Hope that helped!