Updating to the V4 API
1. API URL Path Changes
Base path now includes App Instance ID The 'base path' for API v4 now includes the App Instance ID (the same as the API username used in authentication).
/api/v1/
/api/v4/
backend-deployment-id
/
Use '/objects
' to access objects Accessing objects is now namespaced under '/objects
' in the URL:
/api/v1/
object-name
.json
/api/v4/
backend-deployment-id
/objects/
object-name
.json
Changes to 'datamodel
' and 'oplog
'
datamodel
' and 'oplog
' The 'datamodel
' and 'oplog
' API functions no longer have underscores in their names:
/api/v1/_datamodel.json
/api/v4/
backend-deployment-id
/datamodel.json
/api/v1/_oplog.json
/api/v4/
backend-deployment-id
/oplog.json
2. Response Data Format for Retrieving Multiple Objects
When retrieving multiple objects, the structure of the JSON data returned now namespaces objects underneath an 'objects' key, and metadata such as 'count' of the number of objects in the response, as well as the total number of objects in the collection is also returned:
{
"objects": [
{
"updated_at": "2012-08-29T06:46:10Z",
"name": "Lena Deberon",
"id": "9a700bdc-f115-11e1-bac8-001cc01904e3",
"display": "Lena Deberon"
},
{
"updated_at": "2012-08-29T06:46:17Z",
"name": "Sara Heandy",
"id": "3c2db07a-f1a5-11e1-a7df-001cc01904e3",
"display": "Sara Heandy"
}
],
"count": 2,
"total": 2,
"more": false
}
3. Partial Updates to Objects Should Now Use PATCH Method
In API v1, using the PUT HTTP request method would perform a partial update on an object (e.g. only updating a selected set of the object's fields). In API v4, PATCH must now be used for partial updates.
Failure to change the HTTP request method for partial updates to PATCH will result in data loss!
Partial update to an object in API v1:
PUT https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/tasks/198c990e-f1bf-11e1-8d7d-001cc01904e3.json
task[status]=1
Partial update to an object in API v4:
PATCH https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/tasks/198c990e-f1bf-11e1-8d7d-001cc01904e3.json
task[status]=1
4. PUT Method Will Replace Object Completely
Whereas in API v1, using the PUT HTTP request method will perform a partial update on an object, in API v4, the PUT method will replace the object completely. In other words, fields that are not present (in the object payload provided) will be cleared.
Replace object in API v1:
Not supported in API v1.
Replace object in API v4:
PUT https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/tasks/198c990e-f1bf-11e1-8d7d-001cc01904e3.json
task[status]=1
5. Updated Field Representation for Choice Data Types
"Choice" data types, i.e. single-choice
, single-choice-integer
, multiple-choice
and multiple-choice-integer
now return now the value/key and the display name of the selected option(s):
"status": 1
"status": {"key": 1,"display": "Closed"}
Refer to Field Representation for more details.
6. Changes to Photos and Signatures Response Data Format
In API v4, the response data format for photos and signatures include various changes:
Photos and signatures are no longer included in a separate
display_attachments
field — they are now directly part of the object's fields in the response data.URLs for photos and attachments are now absolute URLs, no longer relative URLs
A
state
field now indicates the availability of the image —pending
oruploaded
.
{
"id": "c3d59ff0-ba4a-11e3-a567-001e6733fe3c",
"type": "task",
"updated_at": "2015-02-05T08:17:58Z",
"display": "Buy Groceries",
"name": "Buy Groceries",
"photo": {
"id": "eacb4836-f1b9-11e1-9750-001cc01904e3",
"state": "uploaded",
"thumbnail": "https://run.journeyapps.com/media/AwNDkyOSJdLFsicCIsI?sha1=12345",
"fullscreen": "https://run.journeyapps.com/media/3JlZW4iXV0W1siZiIs?sha1=12345",
"original": "https://run.journeyapps.com/media/SJdLFsicCIsW1siZiIs?sha1=12345"
}
}
7. New Data Model Naming Conventions
Take note that the Changes in Naming in JourneyApps v4 are reflected when retrieving an app's Data Model.
{
"models": {
"user": {
"name": "user",
"label": "User",
"display": "{name}",
"fields": {
"name": {
"name": "name",
"label": "Name",
"type": "text",
"subtype": "name"
}
},
"belongs_to": {
},
"has_many": {
}
},
"category": {
"name": "category",
"label": "Category",
"display": "{name}",
"fields": {
"name": {
"name": "name",
"label": "Name",
"type": "text"
}
},
"belongs_to": {
},
"has_many": {
"tasks": {
"model": "task",
"name": "tasks",
"inverse_of": "category"
}
}
},
"task": {
"name": "task",
"label": "Task",
"display": "{name}",
"fields": {
"name": {
"name": "name",
"label": "Name",
"type": "text"
},
"instructions": {
"name": "instructions",
"label": "Instructions",
"type": "text"
},
"status": {
"name": "status",
"label": "Status",
"type": "single-choice-integer",
"options": [
{
"key": 0,
"display": "Open"
},
{
"key": 1,
"display": "Closed"
}
]
}
},
"belongs_to": {
"category": {
"model": "category",
"name": "category",
"inverse_of": "tasks"
}
},
"has_many": {
}
}
}
}
8. JSON Response Format Supported Only
Whereas API v1 supports XML and JSON response formats, API v4 only supports JSON.
9. Structured Error Responses
API error responses in API v4 are now more structured, with specific error types:
{
"type": "INVALID_VALUE",
"title": "Invalid value specified.",
"detail": "Invalid option \"test\" for field 'status'.",
"see": "https://resources.journeyapps.com/v4/api/errors/INVALID_VALUE"
}
Last updated