Degraded AWS performance is currently impacting some Canvas users in the North American region. Check Canvas Status for updates.

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

Need Assistance with Canvas COMMONS API: Create Session

Canvas Admin here... I'm average at best with the Canvas API endpoints. We have about a dozen tasks I've created for us that utilize the API, and I can usually do what I need to do.

I've never tried to use the Canvas Commons API before, but I have a need for it now and I cannot even get over the first hurdle of creating a session to get the sessionID. 

Can someone who has gotten this to work, please share the code they use to get a sessionID for the Canvas Commons API?

  1. I'm using the documentation here:
  2. I'm first going to https://[our-canvas-domain]/api/lti/accounts/self/jwt_token?tool_launch_url= and getting a  jwt_token without a problem.
    1. The token I get is around a 3,500 character string, which I assume is good.
  3. I then run the example from the doc:
    curl -X POST -H "Content-Type: application/json" --data '{"jwt_token": "blahblahtokentokentokentoken"}' ""

I get 2 errors returned:
Unmatched closed brace/bracket in column 3622
{"errors":[{"param":"server-error","msg":"There was an error"}]}

I'm pretty sure the brace/brackets are correct. Aren't they? 

I've also trying including the access bearer token, but that doesn't seem to make a difference. Do I need this in there?

If I can just see an example of how to get the student sessionID response, I can take it from there.

0 Kudos
1 Reply
Community Contributor

The following should be functional bash code:


jwttoken=`curl -s -X GET -H "Authorization: Bearer $token" "$url"`

session=`curl -s -X POST -H "Content-Type: application/json" --data "$jwttoken" ""`

sessionid=`echo $session | cut -d'"' -f4`
echo $sessionid