Select fields in API request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, everyone.
I was wondering whether it is possible to select the fields I need instead of receiving full objects when doing API calls. For example, let us assume that I want to get an assignment list for a course, but I only require the id, name and due date, because descriptions and rubrics data are too long and I don't really need them.
I know this might sound a bit pointless; yet consider that in some cases I need to generate Excel sheets using WEBSERVICE formula, and Excel has a cell size limit that triggers an error when the JSON longitude exceeds it.
Any help would be really appreciated.
Regards.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @salvadorperez,
With the REST API, there isn't a way I know of to limit the information returned. You could look at using the GraphQL API, which is much more customizable and does allow you to select what results you'd like returned, but in my opinion might not be quite as friendly for new/amateur users.
I hope this at least answers the question!
-Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I fell under the temptation, and I went to ChatGPT. Now I understand how to do it.
Thank you all, nevertheless.
In short:
- All queries using GraphQL are POST methods (you send the query to the server)
- The URL is this: https://your_canvas_instance/api/graphql
- You need to construct the query JSON in order to select the fields you want (the same fields described in the REST API documentation)
Regards.