The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hello,
I use the behaviour module of ScriptRunner on my Jira environment with 20 differents configurations.
I have two needs :
For the second subject, I saw that I can use the base-url/rest/scriptrunner/behaviours/1.0/config rest API, posting a new XML of my mapping but it's erasing the old one...
I found two other rest API but I don't find any documentation on them :
base-url/rest/scriptrunner/behaviours/1.0/admin/mapping
base-url/rest/scriptrunner/behaviours/1.0/admin/behaviour
I Tried to post the following Json, but it doesn't work...
"
{"id" : 1,
"name": "Behavior1",
"description": "test",
"mappings": [
{
"type": "PROJECT",
"project": {
"id": 20000,
"name": "Project 1",
"key": "P1"
},
"issuetype": {
"id": "0",
"name": "All issue types",}
},
{
"type": "PROJECT",
"project": {
"id": 20002,
"name": "Project 2",
"key": "P2"
},
"issuetype": {
"id": 12200,
"name": "Work Item"
}
}
]
}
"
Any suggestions ?
Thank in advance.
Best regards,
David
I finaly found a solution, this code works :
def http = new HTTPBuilder("yoururl/rest/scriptrunner/behaviours/1.0/admin/mapping")
def authString = "username:password".getBytes().encodeBase64().toString();
http.request(Method.POST, ContentType.JSON) {
headers."Authorization" = "Basic ${authString}"
headers.contentType = "application/json"
body = "{ \"behaviourId\": \"1\", \"type\": \"PROJECT\", \"projectIds\": [\"${projectID}\"], \"issueTypeIds\": [\"10900\"]}"
response.success = { resp, JSON ->
log.warn("Successful = " + JSON)
}
response.failure = { resp, JSON ->
log.warn("Failed = " + JSON)
}
}
break
Thanks for following up your own question and showing it's possible! I'm trying to do this with a python script as part of creating a new project. I'm getting a 200 response, but nothing updates in Behaviors.
def addMapping(p_id, b_id):
print(f"adding {p_id} to behavior {b_id}")
url = f"{BASE_URL}/rest/scriptrunner/behaviours/1.0/admin/mapping"
payload = json.dumps({
"behaviourId": f"{b_id}",
"type": "PROJECT",
"projectId": f"{p_id}",
"issueTypeId": "3"
})
r = requests.request("POST", url, auth=(UNAME, PW), headers=HTTP_HEADERS, data=payload)
rson = r.json()
print("response code = %s" % r.status_code)
print(rson)
addMapping(25701, 6)
I initially omitted "issuetypeid" and played with different names for the projectid, like "projectIds" "id" "ID" etc. TIA.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.