Hi,
When I am testing simple calls like the one below, I get random results! Sometimes it returns 0, sometimes it returns 25 (which is the default pageSize), and sometimes it returns 41, which is the actual number of pages in this space. There's NO consistency. Even adding the -PageSize parameter doesn't change the outcome at all.
(Get-ConfluencePage -Query ("Space='TestSpace'")).count
However, if I don't use Query, but instead use the -SpaceKey parameter, it seems to work every time. It's just that I need to do more than just the SpaceKey filter, and when searching large spaces, this takes a lot longer time to process than the -Query parameter (when its actually working as it should).
Could you look into this and see if there's anything wrong with the code or if there's something I can do differently?
Best regards,
Magnus Jakobsen
Hi @Magnus Jakobsen ,
I'm not aware of any official powershell cmdlets from Atlassian (could be wrong of course).
Could you link us to where you found the information regarding the powershell implementation?
Hi @Dirk Ronsmans
I at least thought it was from Atlassian, but now I'm not sure:
https://github.com/AtlassianPS/ConfluencePS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm afraid not (could be some Atlassian participate but it looks to be an volunteer project)
This is an open source project (under theMIT license), and all contributors are volunteers. All commands are executed at your own risk. Please have good backups before you start, because you can delete a lot of stuff if you're not careful.
Best thing here would be to open an issue on their github repository.
https://github.com/AtlassianPS/ConfluencePS/issues
Here you have a "new issue" button on the top right, this way the developers themselves can respond to any questions/issue you might have!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, looks like that's the only way, or try to get the REST-api working. Thanks for the help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Indeed, using the Invoke-RestMethod should also work, it's a bit more manual work but I've had succes using that in the past.
A basic GET should work like this, you can always adapt the endpoint that you need.
This one just gets a list of the first 250 pages. Since Invoke-RestMethod does not return any response codes I envelop it in a try/catch block in case something goes wrong to catch the exception.
$user = 'xxxxx@email.com'
$token = 'your-api-token'
$pair = "$($user):$($token)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{
Authorization = $basicAuthValue
}
$base_url = "https://yoursite.atlassian.net"
$pages_url = $base_url + "/wiki/api/v2/pages?limit=250"
try{ #get pages
$pages = Invoke-RestMethod -Headers $Headers -Uri $pages_url -Method Get
} catch {
# Dig into the exception to get the Response details.
# Note that value__ is not a typo.
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for this!
Does the V2 API have any search endpoint like the V1 does?
I tried this:
$space = Invoke-RestMethod -Headers $Headers -Uri ($AtlassianConfluence_BaseUrl + "/rest/api/search?cql=space=test&type=page&limit=22") -Method Get
$space.results.Count
And it first gave me a mix of 1 and 22 number of pages back. Which seemed like the same issue I got using the Powershell module. Then after some testing, it started being consistent. I then tried the PS-module again just to verify, and as long as the V1 API is being consistent, so is the PS-module. So there might have been some kind of backend/loadbalancing issue that was the cause of the issue from the start. I will continue doing a bit of testing here to see if I encounter this issue again or if it seems to be fixed now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.