I'm trying to create a script that creates a project as a post-function in Scriptrunner Cloud. I'm using the REST API, but I'm getting 400 errors because of some minor change I need to do. Code snippet is below. What am I missing?
def result = post("/rest/api/2/project")
.header('Content-Type', 'application/json')
.body([
key: newProjectKey,
name: newProjectName,
projectTypeKey: newProjectTypeKey,
projectTemplateKey: newProjectTemplateKey,
leadAccountId: newLeadAccountId
])
.asObject(Map)
if (result.status == 201) {
return 'Success'
} else {
return "${result.status}: ${result.body}"
} What am I missing? Thanks in advance!