REST – Example of a read call with sorting
FollowAs seen in the previous example, you can easily retrieve in JSON format a list containing all the data returned by a view. In a simple context with a small amount of data, you can sort it directly on the client side. If, however, the data volume is significant and you want to leverage Altamira HRM’s query capabilities, you can sort on the server.
You can do this by using the sort parameter in your request. sort supports JSON and can be used to specify a field to sort by and the sort direction to apply.
REST v3 – Read with sorting
You can use any field present in the view to sort the results:
|
Parameter |
Name |
Description |
Type |
|
header |
Token (required) |
Token previously generated by Altamira HRM |
string |
|
header |
environment |
Returns the data formatted according to the value provided.
Available values: Frontend, Mobile, Api
Default value: Api |
string |
|
querystring |
filters |
Filters to apply to the view data. |
string |
|
querystring |
sort |
Column to use for sorting the data.
Available only when the header parameter |
string |
|
querystring |
structure |
Shows the Default value: |
boolean |
|
querystring |
RowNumber |
Pagination: number of rows per page |
int |
|
querystring |
PageNumber |
Pagination: page number |
int |
The Token parameter must be sent as a header.
The sort parameter must be provided in the URL and should have the structure of a JSON object like the following:
{
'sort': {
'tagname': 'Jobs_FullName',
'direction': 'ASC|DESC'
}
}Calling the following URL:
you will get:
{
"count": "1",
"sort": {
"tagName": "Jobs_Title",
"direction": "DESC",
"sortable": true
},
"data": [
{
"Jobs_StatusID": id_value,
"id": id_value,
"Jobs_FullName": "test - test",
"Jobs_StatusName": null,
"Jobs_DatePublished": null,
"Jobs_DateToUnpublish": null,
"Jobs_ReceptionType": "Back office",
"status": {
"statusID": id_value,
"statusName": "Creation",
"statusType": id_value
}
},
{
"Jobs_StatusID": id_value,
"id": id_value,
"Jobs_FullName": "004 - Customer Success Specialist",
"Jobs_StatusName": "Published",
"Jobs_DatePublished": "2028-10-15T12:32:00Z",
"Jobs_DateToUnpublish": null,
"Jobs_ReceptionType": "Back office",
"status": {
"statusID": id_value,
"statusName": "Published",
"statusType": id_value
}
},
{
"Jobs_StatusID": id_value,
"id": id_value,
"Jobs_FullName": "003 - Java Software Engineer",
"Jobs_StatusName": "Published",
"Jobs_DatePublished": "2024-05-16T10:11:00Z",
"Jobs_DateToUnpublish": null,
"Jobs_ReceptionType": "Back office",
"status": {
"statusID": id_value,
"statusName": "Published",
"statusType": id_value
}
},
{
"Jobs_StatusID": id_value,
"id": id_value,
"Jobs_FullName": "002 - International Sales Director",
"Jobs_StatusName": "Published",
"Jobs_DatePublished": "2024-05-17T17:02:00Z",
"Jobs_DateToUnpublish": null,
"Jobs_ReceptionType": "Back office",
"status": {
"statusID": id_value,
"statusName": "Published",
"statusType": id_value
}
},
{
"Jobs_StatusID": id_value,
"id": id_value,
"Jobs_FullName": "001 - Digital Marketing Analyst",
"Jobs_StatusName": "Published",
"Jobs_DatePublished": "2024-05-16T10:21:00Z",
"Jobs_DateToUnpublish": null,
"Jobs_ReceptionType": "Back office",
"status": {
"statusID": id_value,
"statusName": "Published",
"statusType": 2
}
}
],
"result": [
{
"status": "Extracted",
"statusMessage": "",
"details": []
}
]
}The possible values for the direction property are the strings "ASC" or "DESC".
Keep the following recommendations in mind when building queries:
- If the field is not present among the view’s fields, it cannot be used for sorting.
Comments
0 comments
Please sign in to leave a comment.