Help with Rest PUT
Application Type
Mobile

I am consuming a REST API supplied by a 3rd party in my mobile app.

I can get data from the GET functions of the API and then save it in local storage.

The user then changes this data as needed and then has to send it back to the API to update the data on the server using a PUT command.

Now the data Consists of a Service Record which has child records of Service Tasks which also has child records of Service Task Parts.

How do I gather all the data from the local tables and format them into JSON and then send back to the REST API PUT commands body.

I am very new to outsystems so please can I have step by step guides as some of the questions/examples on the forum I have found just have pictures but no detail of what each element in the action does or what the variables are set to.

Here is an example of the JSON I am trying to create

{

    "service": {

        "id": 1,

        "machineID": 1,

        "machineName": "test machine",

        "machineSerialNo": "TNP-111-222-333",

        "serviceStatus": "Open",

        "serviceStartDate": "2021-06-01T00:00:00",

        "serviceEndDate": "2021-06-08T00:00:00",

        "notes": "          "

    },

    "serviceTaskList": [

        {

            "id": 1,

            "serviceId": 1,

            "currentAssemblyID": 1,

            "currentAssemblyName": "Test Assembly",

            "taskName": "Clean doofers",

            "taskQuoteName": "Clean Doofers",

            "taskDescription": "Clena the doofers",

            "notes": " ",

            "serviceTaskPartList": [

                {

                    "id": 1,

                    "taskId": 1,

                    "partId": 1,

                    "partName": "Test Part 1",

                    "qtyNeeded": 50,

                    "qtyUsed": 35,

                    "qtyReturned": 10,

                    "qtyLeftOnSite": 5

                },

                {

                    "id": 2,

                    "taskId": 1,

                    "partId": 2,

                    "partName": "Test Part 2",

                    "qtyNeeded": 500,

                    "qtyUsed": 499,

                    "qtyReturned": 1,

                    "qtyLeftOnSite": 0

                }

            ]

        },

        {

            "id": 2,

            "serviceId": 1,

            "currentAssemblyID": 2,

            "currentAssemblyName": "Test Assembly two",

            "taskName": "Vacuum Buffers",

            "taskQuoteName": "Vacuum Buffers",

            "taskDescription": "Vucuum the buffers",

            "notes": " ",

            "serviceTaskPartList": [

                {

                    "id": 3,

                    "taskId": 2,

                    "partId": 3,

                    "partName": "Test Part 3",

                    "qtyNeeded": 5,

                    "qtyUsed": 3,

                    "qtyReturned": 1,

                    "qtyLeftOnSite": 1

                }

            ]

        }

    ]

}


I have also attached a picture of my local storage in case its a name thing.

Capture.JPG

Hello Matt,


I assume you already consumed the PUT method in OutSystems from your REST API. In that case, if you correctly put the JSON in the request body, OutSystems should've automatically created an input structure for the method correspoding to the JSON.


In this case you just need to fetch your data from the DB / Local Storage and assign it to an input parameter of the structure that was automatically created for your PUT method.


Hope it helps.


Regards,

Bogdan

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.