I am trying to create a new project in Jira from Powershell using REST API.
I have the following code, but it is giving me http error 400. I can't figure out where the problem is, most likely in the json part, but how to pinpoint the exact error?
$npuri = "$baseurl/rest/api/2/project"
$npjson = "{ `"key`": `"MNew`",
`"name`": `"M Software Sample`",
`"projectTypeKey`": `"business`",
`"projectTemplateKey`": `"com.atlassian.jira-core-project-templates:jira-core-project-management`"
, `"description`": `"Example Project description`"
`"lead`": `"userid`",
`"assigneeType`": `"PROJECT_LEAD`",
`"avatarId`": 10262,
`"permissionScheme`": 10342,
`"notificationScheme`": 10000,
`"categoryId`": 10120
}"
$response=Invoke-RestMethod -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -ContentType "application/json" -Uri $npuri -Body $npjson -Method POST
A basic query using same base URL and authentication works.
I don't know where the problem is, but here are some ideas to narrow down the problem:
Hi,
Thanks for your suggestions. Using postman, I was able to clear up the JSON syntax, mostly by removing all unnecessary fields.
I also changed the way the JSON body was constructed:
$hash = @{ key= "KEY";
name= "TG Software Sample";
projectTypeKey= "software";
projectTemplateKey="com.pyxis.greenhopper.jira:gh-scrum-template";
description= "Example Project description";
lead= "userid";
assigneeType= "PROJECT_LEAD"
}
$json = $hash | ConvertTo-Json
After that, a project was created successfully on Jira.
Regards,
Thijs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.