Celebrate Excellence in Education: Nominate Outstanding Educators by April 15!
Found this content helpful? Log in or sign up to leave a like!
What is the best way to check if a user is authorized to create a conversation via the Canvas API for a specific recipient user?
I am seeing odd behavior using this API endpoint:
https://canvas.instructure.com/doc/api/conversations.html#method.conversations.create
The sender is the recipient's teacher. I am getting this response back from the HTTP POST request:
{ "attribute": "recipients", "message": "invalid" }
I looked over the source code, and it seems to indicate that the sender does not have permission to send messages to the recipient.
Source code references:
Hello @SpencerWilliams
Thank you for contacting the Instructure Community. Yes, Canvas does have an API call for this already. "Find valid recipients (users, courses and groups) that the current user can send messages to. The /api/v1/search/recipients path is the preferred endpoint, /api/v1/conversations/find_recipients is deprecated." Your other option is to masquerade as the user or go to the course and check as all conversations are tied to course enrollments.
Here is the Canvas guide:
https://canvas.instructure.com/doc/api/search.html#method.search.recipients
Hi Greydon,
From the API documentation you shared, it seems this only allows to check for the "current user". How would I be able to tell if userA (user_id: 1) can start a conversation with userB (user_id: 2)?
This is what I got so far:
curl $URL -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $TEST_TOKEN" -d '{"user_id": 2}'
How can I specify userA (user_id: 1) as the "current user"?
To participate in the Instructure Community, you need to sign up or log in:
Sign In