The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December. Read our blog post for more info about this change.
Found this content helpful? Log in or sign up to leave a like!
When I create an anonymous discussion, it is not displaying in the response list from the discussion_topics endpoint in the REST API.
The list works for non anonymous discussions.
Is there a work around for this or should I report this as a bug?
EDIT: I have tested POSTing to the same discussion, which does work, the post is added to the anonymous discussion in Canvas. Just wondering if others are having this issue?
Anonymous discussion:
Non anonymous discussion:
Solved! Go to Solution.
Do not report this as a bug, it is working as intended. Perhaps not what you intended, but what Canvas intended.
That URL is for the Get a single topic endpoint. To the right of the header is a link to the source code. It's in discussion_topics_api_controller.rb and the function is show.
When you pull up the source code and search for "def show" to find the function, the first line of the code is "return unless is_not_anonymous"
I would say that it is specifically designed to not return any information for an anonymous discussion.
If you click on the 59 (the row number of the return), you get three horizontal dots and one of the options there is to View Git blame. When you follow that, you see that it was added 5 months ago and the comment was "Show 404 on REST API View if Anonymous".
Part of that patch to the source code was to define if_not_anonymous, which appears to be true only when you're using full anonymity.
I cannot find anything in the documentation there about why that decision was made.
It looks like anonymous discussions fall into the category of new features that use GraphQL but are not backported to the REST API. Canvas is moving more and more to GraphQL and would eventually like everyone to use it instead of the REST API.
That explains why it is disabled and you get the 404 error -- the REST API doesn't support anonymous discussions. When I make a post to an anonymous discussion, it uses graphql to send the post. When you load the page, Canvas makes a graphql query to get the posts.
If you're not familiar with GraphQL, you can access an explorer by adding /graphiql at the end of your Canvas instance. You can then play around and see what information is available.
The graphql connection that it uses is the legacyNode and then a type of Discussion. The _id is the discussion ID that you would have if you were able to use the REST API. Then go down about 20 items to find Discussion and you can select the things that you want to get.
Here's an example of what a simple query might look like.
query getDiscussion {
legacyNode(_id: "78982", type: Discussion) {
id
... on Discussion {
id
title
anonymousState
discussionType
requireInitialPost
}
}
}
That won't get everything, but the idea of GraphQL is to only get the things that you need. You can use the discussionEntriesConnection to get the posts that people have made.
Could you post the API endpoint that you called to make these screenshots?
Sure, here they are.
Anonymous:
https://canvas.newcastle.edu.au/api/v1/courses/2016/discussion_topics/78982
(Actual discussion url here: https://canvas.newcastle.edu.au/courses/2016/discussion_topics/78982)
This one is non-anonymous:
https://canvas.newcastle.edu.au/api/v1/courses/2016/discussion_topics/79082
Do not report this as a bug, it is working as intended. Perhaps not what you intended, but what Canvas intended.
That URL is for the Get a single topic endpoint. To the right of the header is a link to the source code. It's in discussion_topics_api_controller.rb and the function is show.
When you pull up the source code and search for "def show" to find the function, the first line of the code is "return unless is_not_anonymous"
I would say that it is specifically designed to not return any information for an anonymous discussion.
If you click on the 59 (the row number of the return), you get three horizontal dots and one of the options there is to View Git blame. When you follow that, you see that it was added 5 months ago and the comment was "Show 404 on REST API View if Anonymous".
Part of that patch to the source code was to define if_not_anonymous, which appears to be true only when you're using full anonymity.
I cannot find anything in the documentation there about why that decision was made.
It looks like anonymous discussions fall into the category of new features that use GraphQL but are not backported to the REST API. Canvas is moving more and more to GraphQL and would eventually like everyone to use it instead of the REST API.
That explains why it is disabled and you get the 404 error -- the REST API doesn't support anonymous discussions. When I make a post to an anonymous discussion, it uses graphql to send the post. When you load the page, Canvas makes a graphql query to get the posts.
If you're not familiar with GraphQL, you can access an explorer by adding /graphiql at the end of your Canvas instance. You can then play around and see what information is available.
The graphql connection that it uses is the legacyNode and then a type of Discussion. The _id is the discussion ID that you would have if you were able to use the REST API. Then go down about 20 items to find Discussion and you can select the things that you want to get.
Here's an example of what a simple query might look like.
query getDiscussion {
legacyNode(_id: "78982", type: Discussion) {
id
... on Discussion {
id
title
anonymousState
discussionType
requireInitialPost
}
}
}
That won't get everything, but the idea of GraphQL is to only get the things that you need. You can use the discussionEntriesConnection to get the posts that people have made.
Thanks @James ,
Ok, that makes sense, since the anonymous discussion feature is quite new they may have left it off the REST API if Canvas is no longer supporting it.
I was able to use the GraphQL interface to get the anonymous discussion responses.
Thanks for your help!
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in