cancel
Showing results for 
Search instead for 
Did you mean: 
brian_mullins
Surveyor II

as_user_id not working

Good morning,

I've been working on a process to set notifications to off for new parent-observer accounts, and am using the following URL in a PUT to flip the bits, but get an error

.../api/v1/users/self/communication_channels/109328/notification_preferences/new_announcement?as_user_id=102685&notification_preferences[frequency]=never

The error I get back is "Invalid as_user_id". The user who's token I'm using is a full admin, so they should be able to masquerade. The channel ID and user ID being passed above have been verified.

Other calls to the API that do not use the as_user_id seem to be working fine.

I had this working, I thought, a few weeks back, but can't seem to get it going now. 

Thanks for any help offered.

Brian

Labels (1)
Tags (3)
4 Replies
bneporadny
Navigator

Hi Brian,

You may be getting invalid as user id because you're passing in the wrong ID.  

Is the 102685 coming from your sis or the actual Canvas #sis user id

When looking at a user in Canvas if you look in the URL you can see Canvas's user ID assigned to that user at the end of the url‌278371_pastedImage_3.png

Hope this helps.

Brian

Hey  @bneporadny ‌,

Yep, I've checked that the user_id is the canvas user ID, and the channel ID is valid for that user.

BM

robotcars
Navigator

Does it work when trying the Live API? your.instructure.com/doc/api/live

What scripting language?

bneporadny
Navigator

Brian,

I took a few minutes to try this out for you and I was able to get it to work without having to user the as_user_id parameter.

 

First thing I did was user the communication channels api to get the communication channel ID's associated with the particular user account I was testing with. 

278390_pastedImage_1.png

 

I then went to the notification preferences api and plugged in one of the ID's I had gotten from above, entered in the notification I wanted to change and then the frequency and was able to successfully change the notification preference of that particular user without any issues.

 

278391_pastedImage_4.png

 

Hope this helps. If not let me know what you're seeing and I'll be glad to continue to assist. 


Brian