Automate version merging using the private HTTP API

Comments

6 comments

  • Avatar
    Peter Bastian (Edited )

    Hi Elie,

    thanks for contacting us. First of all, REST is not officially supported (and the following information might change in the future without any notice) - please keep this in mind when using the provided information and test it in a safe test environment first.

    We also don't recommend automating the merge functionality, as it requires to choose between the content of the merged versiones - this may lead tothe loss of content.

    When you first call rest/scroll-versions/1.0/versions/{spaceKey}/merge/{fromVersionId}/{toVersionId} an async task is started. The response of this request contains the id of this task.

    You need to watch this task via the URL /rest/scroll-versions/1.0/async-tasks/{taskId}

    After a while, you will get a response like this:

    {"id":"<taskId>", ... ,"result":
    {"conflicts":[{"fromPage":{...},"toPage":{...}}, {"fromPage":{...},"toPage":{...}}, ...],"mergedChangePages":...}}

    In Order to complete the merging task, you need to resolve all the merge conflicts.
    You do this by again sending a request to rest/scroll-versions/1.0/versions/{spaceKey}/merge/{fromVersionId}/{toVersionId}

    But this time you use the "result" value from the first response as the body of the new request. But before you send the request, you add the field "resolvingVersionId" to each entry in the "conflicts" array. The value of that field is the versionId which you want to use for merging. This step is normally done in the UI:


    So the body for the second request would look as followed:

    {"conflicts":[{"fromPage":{},"toPage":{},"resolvingVersionId":"<versionId>"}, {"fromPage":{},"toPage":{},"resolvingVersionId":"<versionId>"}]}

    In the response of the second request you again will get a taskId which you need to observe the task in order to know when the merge task finished.
    I hope this helps you achieving your goal.

    Cheers,
    Peter

  • Avatar
    Phelim McConigly (Edited )
  • Avatar
    Nils Bier

    Hi Phelim,

    looks like your comment got lost - do you have any question regarding this thread?

    Cheers
    Nils

  • Avatar
    Phelim McConigly

    Hi Nils, Im just testing what you mentioned above.

    In a simple test case, I get a 201 from response status - does that mean I dont have to send a second request fulfilling any conflicts in this case?

    Perhaps its only necessary for more complicated scenarios, as in the UI?

  • Avatar
    elie

    Thanks Peter! (sorry, didn't see your answer till now).

  • Avatar
    Peter Bastian

    Hi Phelim,

    when there are no conflicts, the task will finish at the first request. But this also means that no content changed in the version you merged into.

    Cheers
    Peter

Please sign in to leave a comment.

Powered by Zendesk