Select fields in API request

Jump to solution
salvadorperez
Community Member

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.

Labels (1)
0 Likes
2 Solutions
chriscas
Community Coach
Community Coach

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

View solution in original post

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.

View solution in original post