cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
daniellopez1
Community Participant

Request could not be handled (Basic outcomes LTI)

Jump to solution

So after a while I'm finally able to make requests to  the basic outcomes lti

But now I'm getting a Request could not be handled

<imsx_codeMajor>unsupported</imsx_codeMajor>
<imsx_severity>status</imsx_severity>
<imsx_description>Request could not be handled. ¯\_(ツ)_/¯
[EID_70000140915829]</imsx_description>

Anyone have idea of what might be happening?

Here's all the information:

This is the code I'm using

$bodyHash = base64_encode(sha1($xml, TRUE));
$stack = HandlerStack::create();

$auth = new Oauth1([
'consumer_key' => 'key',
'consumer_secret' => 'secret',
'token_secret' => null,
'signature_method' => Oauth1::SIGNATURE_METHOD_HMAC,
'bodyhash' => $bodyHash
]);

$stack->push($auth);

$this->client = new Client([
'base_uri' => $url,
'handler' => $stack,
'auth' => 'oauth'
]);

$options = [
'headers' => ['Content-type' => 'application/xml'],
'form_params' => ["data" => $xml], //maybe here? I've tried with just [$xml] and I have changed the name of "data"
to body, oauth_body_hash, xml to no avail
'debug' => true,
'timeout' => 60.0
];

$response = $this->client->request('POST', $url, $options);

url https://canvas.instructure.com/api/lti/v1/tools/149507/grade_passback
xml <?xml version = "1.0" encoding = "UTF-8"?>
<imsx_POXEnvelopeRequest xmlns = "http://www.imsglobal.org/lis/oms1p0/pox">
<imsx_POXHeader>
<imsx_POXRequestHeaderInfo>
<imsx_version>V1.0</imsx_version>
<imsx_messageIdentifier>12341234</imsx_messageIdentifier>
</imsx_POXRequestHeaderInfo>
</imsx_POXHeader>
<imsx_POXBody>
<replaceResultRequest>
<resultRecord>
<sourcedGUID>
<sourcedId>149507-1134052-6602899-7764833-d31943283e0a7375abc78527b8f15177db5557ed</sourcedId>
</sourcedGUID>
<result>
<resultScore>
<language>en</language>
<textString>0.4</textString>
</resultScore>
</result>
</resultRecord>
</replaceResultRequest>
</imsx_POXBody>
</imsx_POXEnvelopeRequest>
bodyhash wwM/xo7Krs7JaDJ96LZYtIt856Y=
Array
(
[oauth_consumer_key] => key
[oauth_nonce] => 722f1e81297858929639337e366fd6f18ceec2f1
[oauth_signature_method] => HMAC-SHA1
[oauth_timestamp] => 1502293398
[oauth_version] => 1.0
[oauth_body_hash] => wwM/xo7Krs7JaDJ96LZYtIt856Y=
)

After I make a request 


* About to connect() to canvas.instructure.com port 443 (#0)
* Trying 54.175.41.72... * connected
* Connected to canvas.instructure.com (54.175.41.72) port 443 (#0)
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
* subject: CN=*.canvaslms.com,O="Instructure, Inc.",L=Salt Lake City,ST=Utah,C=US
* start date: Feb 03 00:00:00 2017 GMT
* expire date: Apr 09 12:00:00 2019 GMT
* common name: *.canvaslms.com
* issuer: CN=DigiCert SHA2 Secure Server CA,O=DigiCert Inc,C=US
> POST /api/lti/v1/tools/149507/grade_passback HTTP/1.1
User-Agent: GuzzleHttp/6.2.1 curl/7.19.7 PHP/7.1.3
Host: canvas.instructure.com
Content-type: application/xml
Authorization: OAuth oauth_body_hash="wwM%2Fxo7Krs7JaDJ96LZYtIt856Y%3D", oauth_consumer_key="key", oauth_nonce="722f1e81297858929639337e366fd6f18ceec2f1", oauth_signature="niGF39Fx0f4U9VEZeBRo3fVGlUc%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1502293398", oauth_version="1.0"
Content-Length: 1095

< HTTP/1.1 200 OK
< Cache-Control: max-age=0, private, must-revalidate
< Content-Type: application/xml; charset=utf-8
< Date: Wed, 09 Aug 2017 15:43:19 GMT
< ETag: W/"203c3a4ad32049a48f79645aee305d36"
< P3P: CP="None, see http://www.instructure.com/privacy-policy"
< Server: Apache
< Status: 200 OK
< Vary: Accept-Encoding
< X-Canvas-Meta: q=1115;a=10;g=ff2e5780-fa5b-012d-f7b3-123135003972;s=7;c=cluster7;z=us-east-1e;o=lti_api;n=grade_passback;b=1312524;m=1314588;u=0.09;y=0.00;d=0.01;
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-Request-Context-Id: 9241bba0-04bc-47b2-b34f-6c9ca08748c0
< X-Request-Processor: 02c9c513abd4af5cc
< X-Runtime: 0.171460
< X-UA-Compatible: IE=Edge,chrome=1
< X-XSS-Protection: 1; mode=block
< Content-Length: 803
< Connection: keep-alive
<
* Connection #0 to host canvas.instructure.com left intact

And this is the response


<?xml version="1.0" encoding="UTF-8"?>
<imsx_POXEnvelopeResponse xmlns="http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0">
<imsx_POXHeader>
<imsx_POXResponseHeaderInfo>
<imsx_version>V1.0</imsx_version>
<imsx_messageIdentifier/>
<imsx_statusInfo>
<imsx_codeMajor>unsupported</imsx_codeMajor>
<imsx_severity>status</imsx_severity>
<imsx_description>Request could not be handled. ¯\_(ツ)_/¯
[EID_70000140915829]</imsx_description>
<imsx_messageRefIdentifier/>
<imsx_operationRefIdentifier/>
</imsx_statusInfo>
</imsx_POXResponseHeaderInfo>
</imsx_POXHeader>
<imsx_POXBody>
</imsx_POXBody>
</imsx_POXEnvelopeResponse>

Tags (1)
1 Solution

Accepted Solutions
daniellopez1
Community Participant

I got it working. I think it was caused by the form_params and the way guzzle send that request. I found there's another way to make a post request in guzzle

$bodyHash = base64_encode(sha1($xml, TRUE));
$stack = HandlerStack::create();

$auth = new Oauth1([
'consumer_key' => 'key',
'consumer_secret' => 'secret',
'token_secret' => null,
'signature_method' => Oauth1::SIGNATURE_METHOD_HMAC,
'bodyhash' => $bodyHash
]);

$stack->push($auth);

$this->client = new Client([
'base_uri' => $url,
'handler' => $stack,
'auth' => 'oauth'
]);

$response = $this->client->post($url, [
'debug' => true,
'body' => $xml,
'headers' => [
'Content-Type' => 'application/xml'
],
]);

For future reference in case anyone is using guzzle 6, this code is working Smiley Happy

View solution in original post

2 Replies
daniellopez1
Community Participant

I got it working. I think it was caused by the form_params and the way guzzle send that request. I found there's another way to make a post request in guzzle

$bodyHash = base64_encode(sha1($xml, TRUE));
$stack = HandlerStack::create();

$auth = new Oauth1([
'consumer_key' => 'key',
'consumer_secret' => 'secret',
'token_secret' => null,
'signature_method' => Oauth1::SIGNATURE_METHOD_HMAC,
'bodyhash' => $bodyHash
]);

$stack->push($auth);

$this->client = new Client([
'base_uri' => $url,
'handler' => $stack,
'auth' => 'oauth'
]);

$response = $this->client->post($url, [
'debug' => true,
'body' => $xml,
'headers' => [
'Content-Type' => 'application/xml'
],
]);

For future reference in case anyone is using guzzle 6, this code is working Smiley Happy

View solution in original post

Hi  @daniellopez1 a late Welcome to the Community! Thanks for bringing this info here. We always welcome new content especially when it comes to LTI coding. Have you thought of joining the https://community.canvaslms.com/groups/designers?sr=search&searchId=f0031eed-2e8e-4e8d-a8de-6dad5789...‌ space? There is also a https://community.canvaslms.com/groups/canvas-developers?sr=search&searchId=fa157114-5f5a-49d9-ac79-...‌ space where lots of good coding convo is happening and can probably help further your quest for more awesomeness. If you don't mind, I'm going to go ahead and mark this answer as correct since you went ahead and answered it. Smiley Happy Don't hesitate to reach out to get some more feedback! (you were just too quick to answer your own question! )