REST - Example of read call with filter
FollowAs seen in the previous example, we can easily obtain a list containing all the data returned from a view in JSON format. In a simple context, where there is not much data which you need to filter, you can do it directly on the client application side. If, on the other hand, the amount of data is consistent and you want to use Altamira HRM's query capability, then you can associate an incorporated filter to the view.
Once it is associated with an incorporated filter, you can use it in your call using the Filter parameter. Filter supports a simplified query language that you can use to make queries that will be executed on the server before returning results.
Continuing with the previous example:
- Add an incorporated filter to the view
- Add the Vacancies\Base Data\Title field that has the Jobs.Title name tag
REST v2 - Read with filter
As seen in the previous example, we can easily obtain a list containing all the data returned from a view in JSON format. In a simple context, where there is not much data which you need to filter, you can do it directly on the client application side. If, on the other hand, the amount of data is consistent and you want to use Altamira HRM's query capability, then you can associate an incorporated filter to the view.
Once it is associated with an incorporated filter, you can use it in your call using the Filter parameter. Filter supports a simplified query language that you can use to make queries that will be executed on the server before returning results.
Continuing with the previous example:
- Add an incorporated filter to the view
- Add the Vacancies\Base Data\Title field that has the Titlename tag
Now you can use the field to filter the results:
Type |
Name |
Description |
Schema |
header |
Token (required) |
Token generated by Authentication |
string |
Put the Token in the HTTP header and if HTTP Method is GET the Pass Filter JSON as Parameters with Key=“Filters” and if HTTP Method is POST the Pass the Filter JSON in Body and Value of JSON as in Example Below.
Which will return:
{
"Jobs.List.API": [
{
"Jobs.FullName": "XYZ Inc - 0003 - Senior software developer",
"Jobs.State": "/ Currently published /",
"Jobs.DatePublished": "2019-08-17T16: 53: 24.590Z",
"Jobs.DateToUnpublish": "0001-01-01T00: 00: 00.000Z",
"Jobs.ReceptionType": "/ Back office /"
}
]
}
You can also write more complex expressions such as:
{
"filters":[
{
"tagname" : "group",
"comparator" : "AND",
"value" : [
{
"tagname" : "CV.Surname",
"value": "th",
"comparator": "equal|Contains|GreaterThanOrEqual|LessThanOrEqual|isnullorempty"
},
{
"tagname" : "CV.Surname",
"value": "ma",
"comparator": "equal| Contains|GreaterThanOrEqual|LessThanOrEqual|isnullorempty"
}
]
},
{
"tagname" : "CV.Age",
"value": "61",
"comparator": "LessThanOrEqual"
}
]
}
You can see a complete list of logical and comparison operators here.
Keep the following recommendations in mind when building your queries:
- If the field has not been added to the filter from the Altamira HRM GUI, it cannot be used in the API. The API will return an error message indicating that the TagName could not be found in the filter. See the management of incorporated filter
- Each field only supports a few specific operators. If you use an operator that the field does not support, the API will return an error message indicating which operators are supported
- For listtype fields you will need to use the DisplayNamePath attribute as a filter. The display name path texts are translated, so you need to make sure that the same language is being used when requesting the elements of the list which you will use when calling the resource
REST v1 - Read with filter
Now you can use the field to filter the results:
- https://platform.altamirahrm.com/api/v1/altamira/REST/Jobs.List.API?ApiKey=0123456789012345&Filter=Jobs.Title BeginWith "Senior"
Which will return:
{
"Jobs.List.API": [
{
"Jobs.FullName": "XYZ Inc - 0003 - Senior software developer",
"Jobs.State": "/ Currently published /",
"Jobs.DatePublished": "2019-08-17T16: 53: 24.590Z",
"Jobs.DateToUnpublish": "0001-01-01T00: 00: 00.000Z",
"Jobs.ReceptionType": "/ Back office /"
}
]
}
You can also write more complex expressions such as:
CV.Age GreaterThanOrEqual "50"
AND (CV.Surname Contains "th" OR CV.Surname Contains "ma")
AND CV.Age LessThanOrEqual "61"
You can see a complete list of logical and comparison operators here.
Keep the following recommendations in mind when building your queries:
- If the field has not been added to the filter from the Altamira HRM GUI, it cannot be used in the API. The API will return an error message indicating that the TagName could not be found in the filter. See the management of incorporated filter
- Each field only supports a few specific operators. If you use an operator that the field does not support, the API will return an error message indicating which operators are supported
- For list type fields you will need to use the DisplayNamePath attribute as a filter. The display name path texts are translated, so you need to make sure that the same language is being used when requesting the elements of the list which you will use when calling the resource
Comments
0 comments
Please sign in to leave a comment.