Rest Service

Imports, export, webservices, custom integration work, 3rd party software plugins etc. Questions about these topics live here.
joshleigh
Posts: 3
Joined: Thu Jul 06, 2017 3:15 pm

Rest Service

Post by joshleigh »

Hi everyone,

I'm currently building a Rest API/Service for a client and having some trouble. I can't determine whether there's an issue with the data being supplied or something I'm doing within Proclaim.

Firstly, the data being supplied isn't within an array. Straight away, this is an issue as I'm dealing with multiple "segments" of data. In my experience with Rest Services, data within an array will be stored within an iteration table in Proclaim. Without an array, the data cannot be stored in a table. This would mean I could have an infinite number of fields to create to cater for the process. Below is the sample data returned from the service.

Code: Select all

{
    "status": true,
    "0": {
        "client": {
            "id": 209729,
            "case_ref": "Jon Test",
            "title": "Mr",
            "forename": "Jon",
            "surname": "Test1",
            "email": "jon@test.co.uk",
            "mobile": null,
            "status": "Complete",
            "is_joint": false,
            "assigned_user": "Daniel",
            "source_of_request": "Source",
            "created_at": {
                "date": "2021-02-09 10:30:40.000000",
                "timezone_type": 3,
                "timezone": "Europe/London"
            },
            "completed_at": null,
            "expired_date": "2021-03-10 08:00:47",
            "is_downloadable": false
        }
    },
    "1": {
        "client": {
            "id": 210496,
            "case_ref": "Jon -TEST",
            "title": "Mr",
            "forename": "Jon",
            "surname": "Test2",
            "email": "jon.test2@test",
            "mobile": null,
            "status": "Complete",
            "is_joint": false,
            "assigned_user": "Jon Test",
            "source_of_request": "Source 2",
            "created_at": {
                "date": "2021-02-10 11:04:49.000000",
                "timezone_type": 3,
                "timezone": "Europe/London"
            },
            "completed_at": null,
            "expired_date": "2021-03-11 08:02:42",
            "is_downloadable": true
        }
    }
}
Instead, I've tried parsing the data within Proclaim maths/linked action and I could be doing this wrong. Is there a way for me to get the data within the object(s) "0" and "1", and then from within the "client" object within each?

I've done some messing around with JSON-OBJECT, JSON-GET-PROPERTY and I can get as far as the "client" object, and can't do anything with the data. I've used the below code to give me the data within the "client" object.

Code: Select all

RESTSERVICE( "myService" , "myRequest" ) 
JSON-OBJECT-FROMFILE( "myJSON" , "C:\Users\myUserDesktop\Rest Debugging\test.json" ) 
v-names = JSON-GET-NAMES( "myJSON" ) 
MESSAGE( v-names ) 
v-size = LISTSIZE( v-names , "*" ) 
MESSAGE( v-size ) 
v-item = LISTITEM( v-names , 2 , "*" ) 
MESSAGE( v-item ) 
v-type = JSON-GET-PROPERTY( "myJSON" , v-item ) 
MESSAGE( v-type ) 
Any assistance here is appreciated!