Forums

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

How can I use the "cursor" instead of "start" in my code?

Ryland Bangerter
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 26, 2023

I am trying to call api from confluence to bring it over to another site but the parameters from confluence don't want to work for me. At first it was because I was using start, and then I found out it was changed to cursor, which uses a string. 

This is the code I'm working with: 

# Get the list of Jira wiki pages
def get_jira_wiki_pages():

url = "https://cattlecountry.atlassian.net/wiki/rest/api/search?"

auth = HTTPBasicAuth(jira_username, jira_token)

headers = {
"Accept": "application/json"
}

pages = []
i = 0
while True:
params = {
"cql": "type=page",
"cursor": "raNDoMsTRiNg",
"limit": 25
}
print(i)
response = requests.get(
url,
headers=headers,
auth=auth,
params=params
)
try:
response.raise_for_status()
except requests.exceptions.HTTPError as e:
print(f"Error: {e}")
print(f"Response content: {response.content}")
break
response_json = response.json()
pages.extend(response_json.get("results", []))
print(response_json)

print(response_json["results"][0]["title"])
print(response_json["results"])

if len(response_json.get("results", [])) < 25:
break

i += 25
return pages

The bolded line is where I am pretty sure that my code is giving me an error. Right now it's giving a 400 error. 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events