Automate version merging using the private HTTP API
Hello,
I'm trying to automate the process of merging two versions using scroll-versions' private API.
Could you please give me the format of the POST request body for the following private endpoint?
/scroll-versions/1.0/versions/{spaceKey}/merge/{fromVersionId}/{toVersionId}
To clarify, here's the HTTP endpoint I'd like to use (seen from Confluence's REST API browser):
I know all of the required URL parameters (spaceKey, fromVersionId, toVersionId).
I don't know what to put into the "Request Body" field:
- the request fails with HTTP 500 if I leave it empty.
- the data type used is JSON, so I've tried putting in an empty JSON object: {}
The request returns HTTP 200 and registers an async task (so that's better than before :-) ) but it has no impact on the versions (it does nothing).
Could you please give me the format of the JSON data required in Request Body?
Thanks,
Elie
-
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
Please sign in to leave a comment.
Comments
6 comments