Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JSON's 'next': API request from Python (command line) prevent immediate access to certain content?

Emily Kern February 1, 2019

I've tried several API requests in the browser and get expected responses. 

I try the same requests via Python's request lib and execute the script from the command line. However, I get empty results (though the request was registered as valid). I've set the limit to the max (500) and still get no results. 

I understand that the limit refers to the number of items retrieved from the given request based on parameters, but I figured I'd try it out. At this point, I only need to retrieve 1 page so that I can do a POST request. I've tried hard-coding the page id so my API request looks like this:

https://mybaselink.com/rest/api/content/pageidiwant

That request successfully gets the page in the browser, but my Python script says the page does not exist. If my script doesn't see that the page exists, I'm assuming I can't POST to it. 

Does this contradiction have to do with 'next' parameter found in large JSON files? Considering I've made specific arguments, I thought there would be a nonissue here.

1 answer

1 vote
Tobias Anstett _K15t_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 3, 2019

Hi @Emily Kern,

You are basically doing a GET request for the content API /rest/api/content/<YOUR_PAGE_ID>.

If you execute the request from the browser it works because your user is authenticated respectively the browser has a valid cookie.

Executing the request without authentication context will return an error or 0 results because in this case "anonymous" can't see that page - thus it does not work in your script.

To provide this information please read the following articles:

- Confluence Cloud : https://developer.atlassian.com/cloud/confluence/basic-auth-for-rest-apis/

- Confluence Server : https://developer.atlassian.com/server/confluence/using-the-rest-apis-prototype-only/

 

Best, Tobias

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events