Forums

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

conflunce rest api returns 200 status ok with empty results

ShahajaKalivarapu January 31, 2024

Hi, 

I'm trying to connect to confluence rest api using Python requests module. the request returned a 200 status ok but shows empty results `

{\"search.ui.recent.link.text\":\"View more recently visited\",\"search.ui.search.results.empty\":\"We couldn''t find anything matching \\"{
0
}`


below is the code snippet generated from Postman:

import requests

url = "https://confluence.sp.vodafone.com/confluence/rest/api/content/search?cql=spaceKey='BDPL'&text~'BIF'&type=page&title='Neuron-BIF Documentation'"

payload = {}
headers = {
'Accept': 'application/json',
'X-Atlassian-Token': 'no-check',
'Authorization': 'Bearer XXXXXXXXXXXXXXXXXXXXXXX',
'Cookie': 'JSESSIONID=61ADDC1D0BE92FD3E276024CD6A8044A'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)


 Also a little more look into the permission from the request output json shows `

<meta name="ajs-remote-user-has-browse-users-permission" content="true">
hasEditPermissions\":false
applinks.docs.insufficient.remote.permission`
I looked into the internet and couldn't find much information on any of these. Could you help identify the issue here? if it's insufficient permissions, what permissions are required to do the job?
Thank you

2 answers

1 vote
Sunny Ape
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 4, 2024

Hello @ShahajaKalivarapu 

A 200 code means that the request was successful. The response from the API was just stating a fact... it couldn't find anything that matched your CQL

This is because your CQL contains many mistakes:

  1. There is no such field as spaceKey. The field is space.key.
  2. You cannot use ampersands (&) as keywords. The keyword is AND.
  3. You didn't put spaces around the keywords and the operators.

 

All of this is described on the Confluence Server CQL documentation pages.

 

ShahajaKalivarapu February 5, 2024

Thank you for pointing the cql syntax errors. @Sunny Ape

 

0 votes
ShahajaKalivarapu February 5, 2024

what worked for me is the response from this thread -https://community.atlassian.com/t5/Confluence-questions/Does-the-Confluence-REST-documentation-work/qaq-p/1654183

My organisation Confluence is installed at root, so I had to remove /confluence from the path. 

The final working URL in my case was - https://<org confluence domain name>/rest/api/content/search?cql={cql}. This URL returned a response as described here in Confluence Rest api documnetation (https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-search/#api-wiki-rest-api-search-get).

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events