Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-WikiPage -Limit values in the range [1..4] fail to return the page #2

Closed
ScottWelker opened this issue Sep 13, 2016 · 3 comments
Closed

Comments

@ScottWelker
Copy link

In the latest version, and the immediately prior version, Get-WikiPage fails silently for "-Limit" values in the range [1..4] inclusive. However, 0 and seemingly any value above 4 works. Negative values result in an understandable HTTP 500 Server Error from Confluence.

Get-WikiPage -Title somepage -SpaceKey somespacekey -Limit n

Where:

  • somepage exists (and is returned for limits of zero or above 4).
  • somespacekey exists (and is returned for limits of zero or above 4).
  • n is some limit number.

It's of course relatively easy to avoid the issue. Just thought you might want to know.
Oh! And, THANKS!! This tool looks very useful.

@brianbunke
Copy link
Collaborator

brianbunke commented Sep 13, 2016

Thanks man! This helped me realize I haven't yet added ValidateRange on the [int] parameters, so I appreciate the feedback!

I think you're running into an API problem I haven't been able to "hide" at this point. Here's what your command is actually doing, in order:

Get-WikiPage -Title somepage -SpaceKey somespacekey -Limit n

  1. Build the URI:
    • https://wiki.contoso.com/rest/api/content?type=page&spaceKey=somespacekey&limit=n
    • Note that it's ignoring the Title parameter so far
  2. Makes the REST Get call with that URI and your credentials
  3. Uses Where-Object to filter down to Title wildcard matches

This is the part that matters: Inside the space key you supply, it grabs the first n results at random.1 If the first four random results don't match your Title string, they are all filtered out as part of step 3, and then it appears to fail silently.

I have two options here:

  1. Keep it this way. Hopefully not everyone runs into the same problem 😢
    • Maybe I can review the help I wrote for Get-WikiPage and be more explicit about this?
  2. Go back to adding the Title parameter in step 1, BUT:
    • From memory, this makes it case sensitive (like SpaceKey is currently)
    • and I'm pretty sure it also breaks wildcarding

I hated those downsides in option 2, so I went the option 1 route during creation.

Let me know if that makes sense, or please tell me if I misunderstood your problem completely, haha.

1 Random as far as I can tell, anyway. I'm sure there's some rhyme or reason, but I haven't figured it out.

@brianbunke brianbunke self-assigned this Sep 13, 2016
brianbunke added a commit that referenced this issue Sep 13, 2016
@brianbunke
Copy link
Collaborator

And also to add, if that ^ is actually the problem you're running into, do this instead:

Get-WikiPage -Title somepage -SpaceKey somespacekey -Limit 100 | Select -First n

@ScottWelker
Copy link
Author

You've understood completely. I like that last "do this instead". Thank you!

I really appreciate your sharing this. I had to work directly with the Confluence v3.x REST API. ConfluencePS is saving me a bunch of work - for the Confluence v5.x REST API.

Thanks again!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants