I'm trying to get Canvas grade passbook to work. I'm submitting to the endpoint
with the Authorization header
and the Content-Type header of "application/xml". Below is teh body of the request...
<?xml version="1.0" encoding="UTF-8"?>
<text>text data for canvas submission</text>
This is resulting in a 422 Unprocessable Entity error. Can someone shed light on what this error means and what I can do to fix it?
Solved! Go to Solution.
Canvas will let you get away without having the body hash. However, it shouldn't --- the body hash ("OAuth body signing " is a requirement in the IMS outcomes standard.
Other LMS will throw an error if you omit the body hash.
The double quotes are okay per se.
Our test tool at https://lti.netkno.nz/tp shows the headers and xml re send and we have double quotes in the auth header. If you want to compare, you can access the tool with key/secret: myschool.edu/letmein
Looking at your auth header values, I wondering if they need to be url escaped. We have things like oauth_body_hash="0zwSLXnU%2BihAZNZWhfCywpIjI6A%3D"
Bear with me, I'm kinda new at trouble shooting with people here. Can you clarify some questions for me...
The endpoint you shared above doesn't look correct to me, and I'm having a hard time finding /tools as an endpoint in the API without clicking on everything... Closest thing I found External Tools - Canvas LMS REST API Documentation
Are you trying to download canvas account reports? Account Reports - Canvas LMS REST API Documentation
Which, is found in the Accounts/#/Settings > Reports tab, and looks like the following screenshot.
Or are you trying to get something from an LTI? The link and the XML you provided appears to be more about plugging an LTI into Canvas than getting something from Canvas... but maybe I just don't have experience with this usage.
Your thread title got my attention because it's the error I was getting yesterday when I tried executing a POST when I needed to use PUT, now I'm feeling 422 is a little more vague than I thought.
We're attempting to get Canvas' grade passbackk feature to work, as described here -- https://canvas.instructure.com/doc/api/file.assignment_tools.html . This is when our LMS writes back to Canvas' gradebook. The endpoint was dictated by Canvas, in as far as that it came from the value of the "lis_outcome_service_url" parameter that Canvas passed to our system when a student clicks on the LTI link of an external tool assignment created in Canvas.
If all this sounds like a jumble, no worries. I was hoping some Canvas technical person could weigh in as there is little documentation about what the various error codes mean.
Yep, you are doing something I have not explored. Hopefully someone here can assist. If a Canvas Engineer doesn't show up, you might try the irc.freenode.org #canvas-lms chat, most of the conversations in there get more technical than they do here.
It is coming from our J2EE application using the Apache HttpClient library (v 4.5.2).
What does the error mean, in Canvas terms that is?
Just noticed this was fora course canvas.instructure.com
What role does the user making the launch have? If they are an instructor, you will get the 422. Works okay if I use "Student view".
Odd thing is, for normal school installs I've seen, as an instructor you know you cannot do the launch because you do not get a lis_result_sourcedid
Ah, actually, it looks like there is more to this. Seems to also depend on the user role/student preview and also whether the assignment is published/unpublished.
Hmm, or it might have been that my user had both Teacher and Student roles.
I don't know its defined anywhere. You would have to contact Canvas support to try and get specific information.
When its come up in the discussions here, the most common reason is using the wrong method, for example, PUT instead of POST.
But it has also come up when sending the wrong data format, eg., JSON where something else was expected, or trying to use an endpoint with a user_id in it as a user when it was actually necessary to use "self" and masquerade as the user (?as_user_id).