Page History
...
This produces the following resource object:
Code Block | ||
---|---|---|
| ||
{ "address":"6649 N Blue Gum St", "birthdate":"", "city":"New Orleans", "company":"Benton, John B Jr", "county":"Orleans", "email":"jbutt@gmail.com", "first_name":"James", "last_name":"Butt", "notes":"", "picture":"\\WebAppData\\ContactPictures\\1.jpeg", "state":"LA", "url":"http://www.bentonjohnbjr.com", "zip":"70116", "phone":[ { "phone_number":"(504) 621-8927", "phone_type":"Phone 1" }, { "phone_number":"(504) 845-1427", "phone_type":"Phone 2" } ] } |
One of the drawbacks of calling the GetDatabaseItem service is that property names are formatted with underscores (i.e., how they appear in the dictionary) rather than as camel case (which is the conventional format for JSON objects). Another drawback is that the GetDatabaseItem service attempts to create a resource object from all column data (both physical and calculated). This might be undesirable if some of the data is meaningless to the client. Consider the picture property in the above resource object. It references an image file stored locally on the server, which has no value to the client. This can also be problematic if a calculated column encounters a runtime error or is dependent upon information that only exists within an OpenInsight desktop session. To avoid these problems, we will take advantage of the optional ColumnNames and ItemArrayLabel arguments. To keep our sample code simple and concise, we will limit our resource to just the FIRST_NAME, LAST_NAME, ADDRESS, CITY, STATE, and ZIP database columns:
Code Block | ||
---|---|---|
| ||
API contacts.ID.GET KeyID = EndpointSegment ColumnNames = 'FIRST_NAME' : @FM : 'LAST_NAME' : @FM : 'ADDRESS' : @FM : 'CITY' : @FM : 'STATE' : @FM : 'ZIP' ItemArrayLabel = 'firstName' : @FM : 'lastName' : @FM : 'address' : @FM : 'city' : @FM : 'state' : @FM : 'zipCode' HTTP_Resource_Services('GetDatabaseItem', 'CONTACTS', '', KeyID, ColumnNames, ItemArrayLabel) end api |
Our resource object now appears like this:
Code Block | |
---|---|
| |
| |
{ "address": "6649 N Blue Gum St", "city": "New Orleans", "firstName": "James", "lastName": "Butt", "state": "LA", "zipCode": "70116" } |
...