Solved

Start merge session with API call

  • 24 February 2022
  • 4 replies
  • 102 views

Userlevel 2
Badge +5

Hi!

We’re trying to automate our merging and branching with the SF. As stated in this question it’s already possible to execute a merge session, however I'm trying to also create the merge session. To do this I'm executing the following API call: 

POST indicium/iam/sf/start_merge_session
{
"trunk_project_id": "TRUNK_ID",
"trunk_base_project_vrs_id": "1.00_TRUNK_ID_BRANCH_ID_BASE",
"trunk_current_project_vrs_id": "2.00",
"branch_project_id": "BRANCH_ID",
"branch_current_project_vrs_id": "1.00",
"merge_direction": 1,
"description": "Merge TRUNK_ID 2.00 into BRANCH_ID 1.00",

}

However this is returning a 403 Forbidden, am I doing something wrong or is it not yet possible to start a merge session with an API call?

icon

Best answer by Mark Jongeling 24 February 2022, 15:26

View original

This topic has been closed for comments

4 replies

Userlevel 7
Badge +23

Hi Harry,

The parameter "trunk_base_project_vrs_id” is a read-only field and cannot be used inside the API call. It also doesn’t have to be used as the value of this parameter will automatically be filled when you use this task.

To solve it, leave out the parameter and construct the body as follows:

POST indicium/iam/sf/start_merge_session
{
"trunk_project_id": "TRUNK_ID",
"trunk_current_project_vrs_id": "2.00",
"branch_project_id": "BRANCH_ID",
"branch_current_project_vrs_id": "1.00",
"merge_direction": 1,
"description": "Merge TRUNK_ID 2.00 into BRANCH_ID 1.00"
}

 

Userlevel 2
Badge +5

Hi @Mark Jongeling,

With your solution I've managed to start a merge session however I can’t seem to execute this merge session. Is it possible the API call described in this blogpost has changed? I’ve tried adding and subtracting some parameters but unfortunately to no avail. 

Could you point me in the right direction? 

Userlevel 7
Badge +23

Hi Harry,

The task execute_merge_session is not optimized for API use. Due to needing to solve any Conflicts that may appear in your merge sessions, this never was a priority. You can schedule the merge session to be executed if that is a viable alternative for you.

Examples based on merge to Trunk:

To be able to Execute a merge session, you'll have to first stage the task, patch the values and then commit the task:

POST indicium/iam/sf/merge_session([merge_session_id])/execute_merge_session/stage

After staging, Indicium will return what the ID is of the staged resource like this: iam/appl/staged_execute_merge_session(#)

Not required by default but in case you want to change any values:

For each field you need to update, do a patch like so:

PATCH indicium/iam/sf/staged_execute_merge_session(#)
{
"new_project_vrs_id": "2.00"
}

Commit task:

POST indicium/iam/sf/staged_execute_merge_session(#)/commit

This should do the trick although I haven't been able to test this. The code is according to the Docs :smile:

Userlevel 2
Badge +5

Examples based on merge to Trunk:

To be able to Execute a merge session, you'll have to first stage the task, patch the values and then commit the task:

POST indicium/iam/sf/merge_session([merge_session_id])/execute_merge_session/stage

 

Hi @Mark Jongeling , thank you for your response.

Disappointing to hear that the execute_merge_session is not optimized for API use. We’re trying to automate the process of branching and merging so that we can use this more frequently and with smaller changes and consequently we’re expecting that with small changes in projects the occurrences of merge conflicts won’t be often. 

I’ve tried the solution you suggested however when I’m trying to execute:
POST

indicium/iam/sf/merge_session(66)/execute_merge_session/stage


It returns a 401 unauthorized. Are there any additional details I need to add to the body of the request or am I forgetting something else?