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?

28 Replies

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

Sorry, no don't work for Canvas, so cannot access any secret squirrel stuff.

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

dalvarado-nonem
Community Participant

Well hot damn!  That was the answer -- encoding the parameter values in the authorization header.  Thanks!  Let me know when you start your own company so I can come work for you.

Well, I did that some time ago, no vacancies at present.

bmccowan
Community Member

I also ran into a 422 error when submitting grades back to Canvas, but the solution was related to the assignment. When the assignment is created, if the external tool URL isn't the exact URL of an existing tool (excluding additional parameters, e.g. ?x=foo&y=bar), it will fail. For example, if I have created an External App with a launch URL of my.domain.com/lti and in the assignment settings I use my.domain.com/lti/submission, it will fail, even if I included the domain in the app configuration. Also, using an existing LTI library significantly reduces error potential.

rohits_paktolus
Community Participant

Hi Peter,

Thanks for your support.

We are facing the same 422 response issues in the course for all student's assignments. But for all other courses grade service working fine.

Are there any settings changes required for that course?

we would greatly appreciate it if you kindly give me some feedback.

In the assignment settings, did you make sure that the external tool URL is exactly the same as the External App's launch URL?

Hi,

Yes...We already check this...both URL are the same.