Skip to main content

Is there a special trick to closing a question with the API? Maybe a typo in the documentation? I’m really having trouble getting it to work. All I get is a 401 (Unauthorized) error.

I’d appreciate any suggestions. This one is just confusing me! Screenshots below.

Cheers

Mark

 

 

 

 

{
"closed": true
}

The documentation shows false, but that’s just an example of how to toggle it via the API. It needs to be true to close it. False opens it back up. 


But that doesn’t solve your issue with the Unauthorized. 

Here’s what it is: the question has two different Ids (big pain point for me). 

There’s a questionId and a topicId and sometimes there is a public version of the topicId. 

My guess is that you’re using the wrong Id and it’s trying the call on a question that doesn’t exist (often topicId is larger than questionId because it combines all types of topics in the index) so it can’t close a question that it can’t find. 


 Thanks ​@DannyPancratz - I agree, the two different Ids are a little annoying. But that wasn’t the problem. The problem is I was attempting to use the wrong server. I just Googled for insided api and copied the URL from the documentation. But when I noticed the URL looked odd, I went back to my Google search:

 

The different results had a different URL! So, today’s lesson is to make sure to pick the documentation for the correct server. I assume it’s all the same content, except for the URLs that it quotes. 

Doh! Hopefully I won’t do that again. Thanks for taking the time to respond. 


I’m glad you figured it out!