Jira HTTP bad request "Project is required"

Adwait September 19, 2016

Hi I am getting an error 

HTTP Bad request 400

(  "Errormessages " : [], "errors":("project": "Project is required"))

 

my curl command=

curl -D- --user POST --data @C:\Adwait\AdwaitWorkspace\WS2\Login\jira\createJiraIssue.json -H "Authorization: Basic Yuuuuuu" -H "Content-Type: application/json" "http://xxxxx/rest/api/2/issue" -k -o C:\Adwait\AdwaitWorkspace\WS2\Login\jira\createJiraIssue-Output.json

 

my json=

{
"fields":
{
"project":
{
"key":"DevOps_Touch & Feel (DF)"
},"summary":"Performance test","description":"","environment":"","assignee":{"name":"A","emailAddress":"emailid_assignee"},"issuetype":{"name":"Bug"},"labels":["Automation"],"customfield_10222":[{"value":"Test1"}]}}

3 answers

1 vote
TõnisO
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 19, 2016
"project": {
    "key":"DevOps_Touch & Feel (DF)"
}

That is definitely not the Project Key, looks more like the Name.

Adwait September 19, 2016

yes that is the name. What do i need to give as key?

TõnisO
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 19, 2016

Well.. the Project Key, obviously.

ASDDDD or REWR or RQW in the following example

projectkey.PNG

0 votes
harrison.fritz March 3, 2020

The thing that fixed it for me was by adding the follwoing to the JSON. I needed both the key and id of the project. Once you do this it may ask you for some other "required" fields. The easiest way to find the values/id's/keys of these are to curl Get a specific issue and look through the returned json. https://stackoverflow.com/questions/50099499/using-jira-rest-api-how-can-i-get-description-of-a-specific-issue

"project":

{

"id": <YOUR PROJECT ID IN QUOTES>,
"key": <YOUR PROJECT KEY IN QUOTES"

}

0 votes
Rachna Singh February 14, 2017

Were you able to resolve it, Even after adding key , I am getting issue

JSONObject fields = new JSONObject();
JSONObject project = new JSONObject();
project.put("key", "1");
project.put("id", "intqm");
project.put("name","sample");
fields.put("project",project);
//fields.put("project", "1");
// fields.put("issuetype", new JSONObject().put("id", issuetypeid.toString()));
// fields.put("summary", "Test from JiraRestClient");
//fields.put("description", "Lorem ipsum...");

JSONObject issue = new JSONObject();
issue.put("fields", fields);

Suggest an answer

Log in or Sign up to answer