This commit is contained in:
2022-02-08 22:54:50 +00:00
parent 8ea7e1d1bd
commit be820c695f
4 changed files with 45 additions and 114 deletions

View File

@@ -1,10 +1,21 @@
# API response format
AyaNova uses a RESTful API and supports the [JSON](https://www.json.org/) data interchange format exclusively.
No other data formats are supported, your code must supply and consume JSON formatted data.
All developer interaction with the AyaNova API is via the REST server interface only.
## Authentication
The api is secured via JSON web tokens documented in the API Console help page [authentication section](api-console.md#authentication).
## API documentation
Your primary source of information on how to make API requests is the [API explorer console](api-console.md) where every route is documented and can be tested manually before coding.
In addition the AyaNova web app itself is also an extremely helpful source of information, by opening your browser's developer console and initiating actions within the AyaNova web app you can examine the network requests and responses to see how it's done within AyaNova.
## Successful responses
### GET RESPONSE
@@ -17,109 +28,13 @@ All successful GET responses have a standard format:
"id": 150,
"name": "Handmade Rubber Pizza",
...etc...
},
"readOnly": boolean
}
}
```
The results of the response are always contained in the `data` property and could be a single object, a collection or in some cases nothing at all.
HTTP Status Code is set in the header. A ReadOnly property is set on the returned data for the convenience of the client software however note that the server will always determine this independently so if this property is ignored and the client attempts to update the record a error 2004 NOT_AUTHORIZED would be returned.
### GET DATALIST RESPONSE
In the case of a DataList routes support paging and filtering, here is an example paged collection request and response:
Request (note the `offset` and `limit` parameters):
`http://localhost:7575/api/v8/DataList/List?Offset=2&Limit=2&DataListKey=TestWidgetDataList`
Limit must be a value between 1 and 1000.
Response:
```json
{
"data": [
[
{
"v": 3
},
{
"v": "Handcrafted Fresh Keyboard 27",
"i": 3
},
{
"v": 3
},
{
"v": 697.34
},
{
"v": 128
},
{
"v": "2021-01-28T12:10:46.212435Z"
},
{
"v": true
},
{
"v": "Doug Effertz 17 - OpsAdmin",
"i": 18
}
],
...etc...
],
"paging": {
"count": 100,
"offset": 2,
"limit": 2,
"first": "http://localhost:7575/api/v8/DataList/List?DataListKey=TestWidgetDataList&pageNo=1&pageSize=2",
"previous": "http://localhost:7575/api/v8/DataList/List?DataListKey=TestWidgetDataList&pageNo=1&pageSize=2",
"next": "http://localhost:7575/api/v8/DataList/List?DataListKey=TestWidgetDataList&pageNo=3&pageSize=2",
"last": "http://localhost:7575/api/v8/DataList/List?DataListKey=TestWidgetDataList&pageNo=50&pageSize=2"
},
"columns": [
{
"cm": "WidgetName",
"dt": 4,
"ay": 2,
"rid":1
},
{
"cm": "WidgetSerial",
"dt": 5
},
{
"cm": "WidgetDollarAmount",
"dt": 8
},
{
"cm": "WidgetUserType",
"dt": 10
},
{
"cm": "WidgetStartDate",
"dt": 1
},
{
"cm": "Active",
"dt": 6
},
{
"cm": "User",
"dt": 4,
"ay": 3
}
]
}
```
`Previous` or `next` properties will contain "null" instead of an url on boundaries where there is no record to link to.
`columns` collection is the list of columns returned in the same order as the individual data arrays for each object.
Note that the column with the `rid` flag is the default row ID column and contains the object type and id to open for that row which guarantees an openable object for the row regardless of which columns are set to be returned.
HTTP Status Code is set in the header.
### PUT RESPONSE
@@ -183,7 +98,7 @@ An error object will always contain at minimum an [API error `Code`](api-error-c
Here is an example of a more detailed error response showing validation errors on a request:
```json hl_lines="4 "
```json hl_lines="4 "
{
"error": {
"code": "2200",
@@ -225,7 +140,7 @@ Objects that require concurrency tokens to update are the objects that return a
Every update to an object results in a new concurrency token for that object.
In a concurrency error response ([API error code](api-error-codes.md) 2005) and header HTTP code 409 (Conflict) is returned if a user attempts to update a record that was changed by another user since it was retrieved (outdated concurrency token provided).
In a concurrency error response ([API error code](api-error-codes.md) 2005) and header HTTP code 409 (Conflict) is returned if a user attempts to update a record that was changed by another user since it was retrieved (outdated concurrency token provided).
Here is an example:
@@ -244,7 +159,7 @@ Errors not related to validation or concurrency may contain one or more nested `
Here is a sample error response with innererror set:
```json hl_lines="6 "
```json hl_lines="6 "
{
"error": {
"code": "1005",
@@ -256,7 +171,7 @@ Here is a sample error response with innererror set:
"code": "1007",
"minLength": "6",
"maxLength": "64",
"characterTypes": ["lowerCase","upperCase","number","symbol"],
"characterTypes": ["lowerCase", "upperCase", "number", "symbol"],
"minDistinctCharacterTypes": "2",
"innererror": {
"code": "1008"