cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
RichardHumphrey
Community Member

API create course export "invalid export_type"

Jump to solution

Hello-

 I'm automating the archiving of our course content for our department using the Canvas REST API. So far I am VERY pleased! The only part that is not working is creating a new course export using the API. 

I use https://canvas.cornell.edu/api/v1/courses/COURSENUM/content_exports with the token authorization header. The data I'm sending is 

{"export_type":"common_cartridge"}

and the response I get is 

{"message":"invalid export_type"}

The problem is that I don't know how to format the "export_type" json string and I can't find a working example. I know it's only off by a few characters. I believe that export_type is the only string that I have to send to create a new export.

Does anyone have an example of what the POST json should look like to create a new course export in common cartridge format? 

Every other part of this process is working from the scripts, but I have to create the export manually. Checking the progress, listing the exports, downloading the export file, are all working through the API, just not the initial export creation.

Thank you so much for any help!!

=Rich 

 

0 Kudos
1 Solution

Accepted Solutions
RichardHumphrey
Community Member

After looking through many examples of API calls, I tried sending the data but not as JSON.

curl -d 'export_type=common_cartridge' -X POST https://canvas.cornell.edu/api/v1/courses/<COURSNUM>/content_exports -H "Authorization: Bearer <token>" >new-export.json

Creates the new course export and gives me the JSON I need to find the export. I can also find the export with the list exports function, which gives me a list of all exports just by hitting the above URL with a get and no data besides the token header.

So the output is json but the input is not. More working examples would be better since the docs show this variable but since they don't show an actual call, I couldn't figure out how to format it.

Thanks,

=Rich Humphrey

 

View solution in original post

0 Kudos
3 Replies
RichardHumphrey
Community Member

After looking through many examples of API calls, I tried sending the data but not as JSON.

curl -d 'export_type=common_cartridge' -X POST https://canvas.cornell.edu/api/v1/courses/<COURSNUM>/content_exports -H "Authorization: Bearer <token>" >new-export.json

Creates the new course export and gives me the JSON I need to find the export. I can also find the export with the list exports function, which gives me a list of all exports just by hitting the above URL with a get and no data besides the token header.

So the output is json but the input is not. More working examples would be better since the docs show this variable but since they don't show an actual call, I couldn't figure out how to format it.

Thanks,

=Rich Humphrey

 

View solution in original post

0 Kudos
jkesler
Community Member

I am having a slightly different issue with using the API to export courses. For the moment, I am trying to get it to work using curl on the command line, and it works great as long as I don't specify the "select" option as a query parameter, as noted in the Content Exports API Docs

Specifically, this request works:

curl -d "export_type=common_cartridge" -X POST -H "Authorization: Bearer secret" "https://server.instructure.com/api/v1/courses/329697/content_exports"

But this one fails with the error "message":"An error occured", "error_code":"internal_server_error"

curl -d "export_type=common_cartridge&select[]=pages" -X POST -H "Authorization: Bearer secret" "https://server.instructure.com/api/v1/courses/329697/content_exports"

I would greatly appreciate any suggestions as to what I am missing.

jkesler
Community Member

I've made a little headway. The key for the select parameter needs to be the object, and the value is an id of the object. The question I have though, is how to get ALL of a certain object type, such as all pages.

Here's an example of something that is almost working:

curl -d "export_type=common_cartridge&select[pages]=<???>" -X POST -H "Authorization: Bearer secret" "https://server.instructure.com/api/v1/courses/329697/content_exports"

I'm assuming that the <???> should be a page_id or the url of the page (not the full html_url, just the slugged page name), since the API doc says "The value for each key is a list of object ids. An id can be an integer or a string." but I am getting just an empty export package when I supply an id.

I'll keep working on it, but please help if you can.