Create Applicationlink to Bitbucket using JIRA REST API

Dear All,

I am trying to create applicationlinks using curl between JIRA and Bitbucket in our LAB environment.
After we sync our production environment to LAB zo we can test upgrades or other stuff.
Now we would like to automate this copy process and therefore we want to create the applicationlinks to our other altlassian LAB product environments using curl.

Atlassian support has no solution for us, we asked this allready and they pointed us to this forum for a possible solution.

What do we allready know:
Currently we are able to create an applicationlink using curl using the REST URL //localhost/rest/applinks/latest/applicationlinkForm/createAppLink
We have to feed a json formatted file with parameters and then the applink in JIRA is created. Allthough Jira thinks its fine Bitbucket complains about some authentication code is missing.

Using the url //localhost/rest/applinks/latest/applicationlink/1b898a64-776e-33b5-95d7-30bbaa2eb40e/authentication/provider i can get the providers configured for this link, tike two legged authentication, and accoring to the wadl file i can also ‘PUT’ the configuration for the link ID 1b898a64-776e-33b5-95d7-30bbaa2eb40e.

Also i can retreive the authentication consumer using the URL: //localhost/rest/applinks/latest/applicationlink/1b898a64-776e-33b5-95d7-30bbaa2eb40e/authentication/consumer which gives me some RSA key from the Bitbucket server.

Also using this URL i can put this configuration … accoring to the wadl.

Unfortunatly at this moment i can not add up the numbers …

If i configure the application link should i then configure the authenticationproviders and thirdly the consumer ?
Is there any scematics or documentation of this process ?

Does anyone has a solution or an how-to like description how to do this ?