Accept: application/jsonto confirm that your app is expecting JSON back from the API.
POST/PUTrequests with a
Content-Type: application/jsonheader and send a well-formed JSON payload.
GETrequest to load a resource or a collection, you'll get a response like this.
datais the JSON representation of the resource requested, or an array of objects if you requested a collection
linksoptional; when specified, it is an array of useful links. Resource collections always include links for “next”, “prev”, “first”, “last”.
metaoptional; misc information that varies based on endpoint. Resource collections should include “count”, “total_count*, “page”, “total_pages”.
countthe number of results to return
pagethe page you are requesting
linkswill contain some useful links to help you paginate:
nextURL to the next page of results
prevURL to the previous page of results
selfURL to the page you requested
firstURL to the first page of results
lastURL to the last page of results
metawill contain some useful data:
totalis the total count (all matching resources)
pageis current page number
per_pageis a count of the number of resources returned to you on this page
total_pagesis the total number of pages for this request
idsparameter where you can provide specific IDs for resources you want to retrieve. This makes it easy to load multiple objects at once.
POST, the API will simply return a
204 No Contentempty response to acknowledge that the request succeeded. When you create a resource with a
PUTrequest, the API will return a
Locationheader will be supplied with the full URL to the API endpoint where you can
POST/PUTrequest return the full resource automatically (i.e. you want to use it right away), you can submit your request with the
?follow_location=1query string parameter. This will cause the API to return the resource as if you did the GET yourself.
429 Too Many Requestserror.
statuswill be the HTTP status code that most closely matches the error.
codeis a DeskPRO specific string to represent the specific error that happened. You may
messageis a human-readable English string that describes what went wrong. This value is typcially
errorsproperty is an object that has two properties:
errors.errorsis a JSON array of error objects that happened on a global level (not specific to any one input).
errors.fieldsis a JSON object that has a property for every expected input name that had an error. Inside of each field is a property named “errors” which is an array of error objects (code/message).