I have a Confluence site and I want to pull information about the pages via the Confluence REST API. I'm using a CQL query: `cql=type=page and space=SpaceName`, so my URI is this:
https://<confluence server>/confluence/rest/api/content/search?cql=type=page+and+space=SpaceName
I can log into Confluence from a web browser, then navigate to the above URL and I see all the content in JSON format.
However, when I run `Invoke-RestMethod` in PowerShell, using the exact same credentials and exact same URI, it's successful but there are 0 results:
$uri = "https://<confluence server>/confluence/rest/api/content/search?cql=type=page+and+space=SpaceName"
Invoke-RestMethod -Uri $uri -Credential $credential -Method Get
results : {}
start : 0
limit : 25
size : 0
cqlQuery : type=page and space=SpaceName
searchDuration : 20
totalSize : 0
_links : @{self=https://<confluence server>/confluence/rest/api/content/search?cql=type=page+and+space=SpaceName; base=https://<confluence server>/confluence; context=/confluence}
I don't know if the issue is with the Confluence server not acting right, my credentials, or `Invoke-RestMethod`. Is it possible that the Confluence server could be permitting queries/providing different results via a web browser but somehow not programmatically/PowerShell?
I found this question which is similar but that user is getting an error that appears to be a credential issue. I'm not getting any errors when I query from PowerShell, and I actually get content returned but the results are empty. I've even tested incorrect credentials and it throws an error, so I know the credentials I'm using are correct since I wouldn't get anything back if it wasn't.
Anyone know what's going on here?