API & Webhooks

API Browser Quick Grabs: Listing Locations

  • 17 March 2023
  • 3 replies
  • 251 views

Userlevel 7
Badge +3

This guide is the third in a new series of new guides brought to you by @Bfarkas. Links to his other API Browser Quick Grabs guides can be found at the end of this article.

 

When it comes to managing the locations for in person classes, there is a nice way to upload new locations in bulk. If you want a listing of all current locations in the system, however, you are stuck to paginated front end UI. Fortunately, there is a simple API call to get you this information. This is a GET endpoint meaning you are simply viewing the information and will not cause any changes to the system.

 

 

Listing Locations

  1. Access your Docebo instance’s API Browser by going to: https://<yoursubdomain.docebosaas.com>/api-browser/ 


     

  2. On the ‘Services’ menu select ‘learn’ if it is not already selected.
     

  3. Scroll down the left side to find and select the ‘Location’ category.
     

  4. Select the ‘Returns list of Locations’ option.


     

  5. There are 4 fields in the center area to be aware of:

    1. sort_attr: This sets which piece of data about each location is used to sort the order of the list. By default (leaving the field blank) this will be the unique Docebo ID assigned to the location. If you prefer to sort differently you can enter ‘name’ into this field. 

    2. sort_dir: You can set the order of the attribute you selected in the previous field to be ascending or descending. By default (leaving the field blank) it will be descending, if you want it to be ascending put ‘asc’ in the field.

    3. page_size: This endpoint can produce very long lists. To avoid performance issues, it will make pages of results. This lets you set how many items show up on a page. By default it is 10 items. The maximum size is 200 items. Enter an appropriate number for your needs here.

    4. page: As mentioned above, this endpoint can produce very long lists. To avoid performance issues, it will make pages of results. This field lets you choose which of those pages you view in the output. For example, if you have 50 locations and the page size is set to 20, 3 pages will be generated. When you initially run the endpoint, you will see items 1-20. If you put a 2 in this field, you will then get items 21-40. Put a 3 in this field to get 41-60.
       

  6. Enter the appropriate information in the fields described above.
     

  7. Select the ‘OAUTH’ button underneath the options and sign in if you have not done so already.


     

  8. Select the ‘Try’ button.


     

  9. The request and response should open in the middle of your screen:


     

  10. The information about the locations will be found in the ‘Response Body’ box. If you are comfortable reading or using JSON formatted data, you can simply use this box as isyou are done! If you want this data in a table format, keep reading.
     

  11. Copy all the information in the ‘Response Body’ box to your clipboard.
     

  12. Navigate to https://www.convertcsv.com/json-to-csv.htm


     

  13. Under ‘Step 1’ use the ‘Enter Data’ tab and paste the Response Body information into the box:


     

  14. Scroll down to ‘Step 3’. You will see a preview of your data as a comma separated block (which can be copied to your clipboard if you want) as well as a table.


     

  15. There are two buttons to download your results, one as a CSV (Download Result) and one as an Excel file (JSON To Excel). Select either or both of these to download.

Tip: Change the name in the ‘Save your result’ box to your preference prior to downloading. This will be the file name of both the CSV and the Excel file you download.

 

  1. Open your file and manage away!

     

That’s it! You now have a nice file with all your current location information. Easily sort, verify, and update the information using it. That wasn’t so bad, right? Enjoy!

 

More API Browser Quick Grabs:

Listing Groups

Bulk Update Course information

Bulk Unenroll Users from Courses or Learning Plans

Bulk Update User’s Enrollment to a Completion

Bulk Enroll and Mark User Complete in a Course

Bulk Create Power User

Bulk Remove Power User Level from Users

 

How do you use the API Browser? Are there any endpoints you don’t understand or use cases you’re looking for input on? Comment below!


3 replies

Userlevel 5
Badge +2

Great article @Bfarkas! Our company would be bothered by sharing that information with a website.

But I found a way to do this in Excel with only minor editing of the output from the API. I first dump into Notepad ++ and then copy it into Excel. Then some minor trimming at the beginning and end.
It is no where near as nice as your Groups solution. 😉

I use nested Index, Row, and Column functions to transform the data from a vertical column to horizontal

Userlevel 7
Badge +3

Yup, one of the other low key goals of the series was to show different ways to manipulate the outputted JSON so that folks could find whatever they are most comfortable with. If you want to live in excel, there are a few macro’s out there that would take JSON and convert to tables too (just not a fan of sharing excel macros).

I do plan on making a version of the group management for locations at fark.tools as well, I know you led with not entering the data into a website, but none of the content is saved there, simply handle the manipulation for you on top of the API call. Will circle back once released.

Userlevel 5
Badge +2

Thanks @Bfarkas I will give it a shot! I grabbed the beta (I think) of the group one from fark.tools.

Reply