azure-devopsazure-devops-wiki

Azure DevOps set wiki page order over REST API


The Pages - Create Or Update articel describe how to edit/create a wiki page over the REST API.

But is it possible to edit also the order of the wiki pages?

Simply add order information to json will not work.

$json = @{ "content" = "$md"; "order" = [array]::IndexOf($files, $file) } | ConvertTo-Json

What also will help:

Order 0 is the "home" page and stand always at the top. Is it possible to skip the home page when using REST API. So that in result the wiki have no "home page"?

Any idea?


Solution

  • It is possible to edit the order of wiki pages using the DevOps REST API. You need to create a new Page move and specify the path and new order of given page (0 is for top position).

    POST https://dev.azure.com/{organization}/{project}/_apis/wiki/wikis/{wikiIdentifier}/pagemoves?api-version=7.1-preview.1
    organization = your DevOps organization
    project = your DevOps project
    wikiIdentifier = your Wiki ID (can be extracted from the URL when you have the wiki open in browser, e.g. https://dev.azure.com/myorganization/myproject/_wiki/wikis/**myproject.wiki**/11/My-Test-Page)

    with header:
    'Content-type': 'application/json'

    with authentication:
    via personal access token

    with body:

    {  
        "path": "/My Test Page",  
        "newOrder": 0  
    } 
    

    Official documentation: https://learn.microsoft.com/en-us/rest/api/azure/devops/wiki/page-moves/create?view=azure-devops-rest-7.1&tabs=HTTP