Get Course/Account timezone

21 views
Skip to first unread message

DZ

unread,
Mar 27, 2015, 6:11:19 PM3/27/15
to canvas-l...@googlegroups.com
I am trying to get the course or the account's timezone through the API. I have the timezone configured in my course.

I'm trying this call  

GET /api/v1/accounts/:id


which is supposed to return an Account object containing the timezone, but I'm only getting back the following parameters:
-id
-name
-parent_account_id
-root_account_id
-workflow_state

Cody Cutrer

unread,
Mar 30, 2015, 12:14:20 PM3/30/15
to canvas-l...@googlegroups.com
DZ,

On an account, the timezone is exposed as the default_time_zone attribute. It is not currently exposed on courses.

Cody Cutrer
Software Engineer
Instructure

--

---
You received this message because you are subscribed to the Google Groups "Canvas LMS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dama...@gmail.com

unread,
Mar 31, 2015, 3:38:23 PM3/31/15
to canvas-l...@googlegroups.com
Right, I know it's an account parameter, but when I GET an account Canvas is not returning the default_time_zone attribute. 

Cody Cutrer

unread,
Mar 31, 2015, 3:50:21 PM3/31/15
to canvas-l...@googlegroups.com
Do you have an example of the raw JSON you're getting back from Canvas (or a full URL--_without_ an access token-- of a Canvas Cloud hosted instance that you're seeing this)? Feel free to send that in a private e-mail if you would like to. There are no conditionals on that part of the response - it's always there (as are several others that you don't mention in your previous e-mail). I'm suspicious that any libraries or wrappers you are using is not passing the full response through.

Cody Cutrer
Software Engineer
Instructure

Dámaris Zarco

unread,
Mar 31, 2015, 5:44:35 PM3/31/15
to canvas-l...@googlegroups.com
Cody,

Thanks for your help.

This is my request and the json  I'm getting back:

{"id":631,"name":"Management","parent_account_id":504,"root_account_id":16,"workflow_state":"active"}

Dámaris Zarco

--

---
You received this message because you are subscribed to a topic in the Google Groups "Canvas LMS Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/canvas-lms-users/KBmdFaySvVY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to canvas-lms-use...@googlegroups.com.

Cody Cutrer

unread,
Mar 31, 2015, 7:32:58 PM3/31/15
to canvas-l...@googlegroups.com
Ah, I see. If you only have read-only access to an account, those are the only fields you get: https://github.com/instructure/canvas-lms/blob/stable/lib/api/v1/account.rb#L39.  I'll have to look into this when I'm in the office tomorrow, to understand why the restriction and if can we add other fields to the readonly response.

Cody Cutrer
Software Engineer
Instructure

Cody Cutrer

unread,
Apr 1, 2015, 11:38:58 AM4/1/15
to canvas-l...@googlegroups.com
So the reason for the restricted result is that you are only a teacher, not an admin. However, I see no reason to leave default_time_zone out of the restricted result. I just pushed a change up for review to add it. Assuming all goes well, it should be in production 4/25.

Cody Cutrer
Software Engineer
Instructure

Dámaris Zarco González

unread,
Apr 1, 2015, 12:42:35 PM4/1/15
to canvas-l...@googlegroups.com
That's fantastic!
Thank you so much


--
Dámaris Zarco 

Dámaris Zarco

unread,
Apr 2, 2015, 1:59:05 PM4/2/15
to canvas-l...@googlegroups.com
Cody,

I am running into another issue (not related to the account).

When I try to update a module item I get some funky results.

1. If I try to update the Position it only works if I'm incrementing the position of the item (going from a position of 1 to 2 works fine - going from 2 to 1 doesn't).

My PUT requests is as follows:

https://uvu.instructure.com/api/v1/courses/343331/modules/457097/items/2885671?module_item[title]=My New Title&module_item[published]=true&module_item[position]=1&access_token=

With this request I was able to update the title, but not the position.



2. When I try to update the Title of the item, if that's the only thing I'm updating then it works fine, but if in my PUT request I try to make changes to the published and position properties, the title is not being updated (the other properties are updated just fine)

My PUT requests look like so:

https://uvu.instructure.com/api/v1/courses/343331/modules/457097/items/2885671?module_item[title]=My  New Title&module_item[published]=true&module_item[position]=2&access_token=


With this request the published & position properties were updated but the title wasn't.

Any help would be much appreciated.

Dámaris Zarco
Reply all
Reply to author
Forward
0 new messages