cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
dalvarado-nonem
Community Participant

Getting a 422 (Unprocessable entity) error when attempting to execute grade passback

Jump to solution

I'm trying to get Canvas grade passbook to work.  I'm submitting to the endpoint

https://canvas.instructure.com/api/lti/v1/tools/208981/grade_passback

with the Authorization header

OAuth oauth_body_hash="6MfU9ZcvzMc6XPbdd1PNwiTF1d8=",oauth_nonce="ZiKbzAr8iYsoaUvEFKVV8t1tSrLnhfL6",oauth_signature="0J0XinNaZycfv0UoHcSpCJGYm6M=",oauth_consumer_key="OBSCURED",realm="",oauth_version="1.0",oauth_timestamp="1525367433",oauth_signature_method="HMAC-SHA1"

and the Content-Type header of "application/xml".  Below is teh body of the request...

<?xml version="1.0" encoding="UTF-8"?>

<imsx_POXEnvelopeRequest xmlns="http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0">

  <imsx_POXHeader>

    <imsx_POXRequestHeaderInfo>

      <imsx_version>V1.0</imsx_version>

      <imsx_messageIdentifier>3vG8bzKSKnQznI6Hk9alccMTlvHu0SqQ</imsx_messageIdentifier>

    </imsx_POXRequestHeaderInfo>

  </imsx_POXHeader>

  <imsx_POXBody>

    <replaceResultRequest>

      <resultRecord>

        <sourcedGUID>

          <sourcedId>208981-1290816-8386147-13666019-c6d8c979d6aa1b99f7b8b4947f6135f474e1111a</sourcedId>

        </sourcedGUID>

        <result>

          <resultScore>

            <language>en</language>

            <textString>0.08333333333333333</textString>

          </resultScore>

  <resultData>

            <text>text data for canvas submission</text>

          </resultData>

        </result>

      </resultRecord>

    </replaceResultRequest>

  </imsx_POXBody>

</imsx_POXEnvelopeRequest>

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?

2 Solutions

Accepted Solutions

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.

View solution in original post

0 Kudos
pklove
Community Champion

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"

View solution in original post

28 Replies
robotcars
Community Champion

Dave,

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.

275219_Screen Shot 2018-05-03 at 2.40.03 PM.png

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.

Hi,

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.

kona
Community Coach
Community Coach

 @dalvarado-nonem , I just shared this with the Canvas Developers‌ and Canvas Admins‌ groups in the Community to see if they can help. 

pklove
Community Champion

At first glance the headers and xml look okay.

How are you doing the post?

dalvarado-nonem
Community Participant

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?

pklove
Community Champion

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

pklove
Community Champion

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).