Need help with a PUT call to set notification preference in Canvas API that is failing (CURL & API)

Jump to solution
Community Participant

I am trying to set notification preferences in Canvas (instructure) LMS using CURL. I can get all the preferences so the User and communication channel is fine. I can put some other data but not a new notification preference. Eventually I would like to put a value for the category, but for now just trying to set one notification preference

**This command works fine - get the value of the notification preference**
curl.exe https://<myschool> -H "Authorization: Bearer <token>"


**This command works fine (example of a put via curl)**
curl.exe -d wiki_page[body]=”something new” -X PUT -H "Authorization: Bearer token"

**This command fails - trying to put a new value for the notification preference**
curl.exe --verbose https://<myschool> -d notification_preferences[frequency]=”immediately” -X PUT -H "Authorization: Bearer <token>"

**ERROR in HTML:**
There was a problem with your last request.
You may have tried to perform an action after a long period of inactivity.
If that's the case, try going back, reloading the page you were working on, and resubmitting.
If not, please let us know what you were doing when the error happened.

**ERROR inside the CURL RESPONSE:**
HTTP/1.1 422 Unprocessable Entity

Any help is appreciated

Labels (2)
1 Solution
Community Champion

It doesn't explicitly state it, but in the GET requests there is a :user_id, and in the PUT requests it's just self and only self will work, even for yourself as an admin.


curl --verbose  "https://*[frequency]=immediately" -X "PUT" -H "Authorization: Bearer $token"

curl --verbose  "https://*" -d "notification_preferences[frequency]=immediately" -X "PUT" -H "Authorization: Bearer $token"


View solution in original post