Question

Which API Call to use to Get courses with specific Additional Field values

  • 1 June 2022
  • 1 reply
  • 100 views

Userlevel 1

What is the best API call to get all the courses that have a specific value in an "additional_field".

For example we have created an additional field named “MGR_APRVL_REQD”.  When the course is created the “MGR_APRVL_REQD” is set to “Yes”.  I need to use an API call to get all the courses where this field = “Yes”.

Which API Call would work the best?   And what does the JSON call look like?  Thanks in advance for sharing.


1 reply

Userlevel 4
Badge

I don’t have the full answer here, but I’m bumping this question in the hope that someone else knows what I’m missing:

The first thing to note is that where Additional Fields are concerned, Docebo’s API Browser is sadly of no use:

it is not possible to test additional fields from the API browser. As an example, if you want to filter courses according to a course additional field value where xx is the additional field ID (such as field_1, field_2, etc), the string to use would be something like:

https://yourdomain.docebosaas.com/learn/v1/enrollments?field_6=3
The ID to use in your query instead of xx will either be an integer (for example, for dropdown additional fields), a string (for a text additional field), an array, or a date (for date additional field).

But this is not going well for me.

I only have one course additional field set up:

{
"data": {
"items": [
{
"id": 1,
"type": "dropdown",
"association": "course",
"show_field": true,
"mandatory": false,
"sequence": 0,
"filterable": false,
"multi_choice_filter": false,
"json_config_filter": "",
"actions": [
"edit",
"duplicate",
"delete"
],
"name": {
"type": "single_value",
"value": "Mandatory Course",
"values": []
},
"dropdown_options": {
"1": {
"type": "single_value",
"value": "Yes",
"values": []
},
"2": {
"type": "single_value",
"value": "No",
"values": []
}
}
}
],
"count": 1,
"has_more_data": false,
"cursor": null,
"current_page": 1,
"current_page_size": 10,
"total_page_count": 1,
"total_count": 1,
"sort": [
{
"sort_attr": "sequence",
"sort_dir": "asc"
}
]
},
"version": "1.0.0",
"_links": []
}

I’m trying to get a list of all mandatory courses through the API.

Neither this:

https://yourdomain.docebosaas.com/learn/v1/courses?field_1=1

nor this:

https://yourdomain.docebosaas.com/course/v1/courses?field_1=1

work for my use case: both return all courses.

I know that the field is field_1 and the value is 1, because of what the Additional Fields API call returned above, but also because the course/v1/courses API call includes in its response courses like this one (which is mandatory):

{
"id": 546,
// ...
"field_1": "1",
// ...
}

Any insights anyone can share would be very helpful. Have I found a bug, or am I just missing something with regards to how such filters are intended to work?

Reply