Community

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mgibson2
New Member

canvas api create module item Discussion getting content not found (but SubHeader works fine)

Jump to solution

Hi Im making this call to api

https://k12com.instructure.com/api/v1/courses/589/modules/2454/items?module_item[title]=titlesilly&m...

and getting back 

{"message":"Could not find content"}

Which seems to be the catchall error. 

If I do https://k12com.instructure.com/api/v1/courses/589/modules/2454/items?module_item[title]=titlesilly&m... it works fine - so the ids in there work. (Ive have that course id and Ive create the module 2454)

Also fails if I take out completion requirement still fails. So it seems like the Discussion type is not flying - is there other params I should be using? Am I doing something wrong? The docs list "Discussion" as a valid type : https://canvas.instructure.com/doc/api/modules.html#method.context_module_items_api.create

 

Thanks for your help Mark Gibson

 

Labels (1)
Tags (2)
0 Kudos
2 Solutions

Accepted Solutions

Did you already create a Discussion?  When trying to link a Discussion to a Module, I think the Discussion already needs to exist so that you can get the id of the Discussion to then use in the API call.

View solution in original post

0 Kudos

yea finally figured it out - needed to create a DiscussionTopic - is there some tutorial that makes these kind of things clear? how one has to wire things? if there is I havent found it yet - having same issues with File/Dropbox

View solution in original post

0 Kudos
9 Replies
mgibson2
New Member

I see the urls get truncated in the message - the 1st failing url has type Discussion, the 2nd working one has type SubHeader

James
Community Champion

@mgibson2 ( Mark )

Without testing this on my own to confirm, it appears that you're missing part of the completion_requirement field. When you look at the documentation, there is a [type] at the end. For me, it appears on a separate line so it would be easy to miss.

It should be: module_item[completion_requirement][type]=must_contribute

 

mgibson2
New Member

james - thanks for your response

and i was sure you nailed it - i didnt relly understand what that [type] on the newline was about

so i tried 

https://k12com.instructure.com/api/v1/courses/589/modules/2454/items?module_item[title]=titlesillyy&...

but got same "could not find content" error - hmmm - thought that was it - i wish the error messages were a little more informative as im not sure why canvas doesnt like my request - does anyone have a working discussion request i could look at? - thanks!

oh i forget it chops the url - anyways i put at the end of my url

https://k12com.instructure.com/api/v1/courses/589/modules/2454/items?

module_item[title]=titlesillyy

&module_item[type]=Discussion

&module_item[completion_requirement][type]=must_contribute

and still failing - will fiddle around with it a little more and see if i can get more clues

 

and fyi this does work...

https://k12com.instructure.com/api/v1/courses/589/modules/2454/items?

module_item[title]=titlesillyy

&module_item[type]=SubHeader

&module_item[completion_requirement][type]=must_contribute

just changing type to SubHeader - i do wonder if Discussion has other required params - but if it does it isnt mentioned in the docs

 

oh i found the problem - it needs a content id - but this just leads to another question

what should the content id of a discussion point to? not a quiz id right?

thanks for help

Did you already create a Discussion?  When trying to link a Discussion to a Module, I think the Discussion already needs to exist so that you can get the id of the Discussion to then use in the API call.

0 Kudos

yea finally figured it out - needed to create a DiscussionTopic - is there some tutorial that makes these kind of things clear? how one has to wire things? if there is I havent found it yet - having same issues with File/Dropbox

0 Kudos
JamesSekcienski
Community Participant

I'm not sure if there are any tutorials on the specifics of understanding the API documentation.  A lot of what I've learned is through reading the API documentation for what I want to do multiple times, seeing if someone else posted about it in Canvas Community yet, and/or trial and error.

For File, if you are trying to add a Module Link to a File, then similar to a Discussion, you likely need to ensure the File already exists in the course.  You could also try adding a File and manually adding it to a Module.  Then, use the API call to get the Module Items and check the settings for the File item to ensure you are using the proper settings when you try to create it with an API call.