8

I am trying to create issue using Jira REST API including component. I am posting this JSON but I get The remote server returned an error: (400) Bad Request.

Issue is:- Without component there is no error, but when component is there issue created. Any help? JSON:

{
  "fields": {
    "project": {
      "key": "keyGoesHere"
    },
    "assignee": {
      "name": "name.surname"
    },
    "component": {
      "name": "someName"
    },
    "summary": "test2",
    "description": "test2",
    "issuetype": {
      "name": "Task"
    }
  }
}

2 Answers 2

22

I found the answer. Just in case someone needs it.

"components": [{
  "name": "someName"
}],
Sign up to request clarification or add additional context in comments.

1 Comment

You are a godsend!
0

A fully working example for to create a jira issue including extension. Two option will likely be different

  • the url path /<-option-jira>/ could be non existing on your server
  • the customfield number from customfield_10228 will likely be different or you do not have it at all if your installation does not have
### Create Issue as Test with steps the option-jira may be NULL in your setup
POST https://exmple.com/<-option-jira>/rest/api/2/issue/
Authorization: Bearer <your_token>
Content-Type: application/json

{
  "fields": {
    "project": { "key": "XAMPL" },
    "summary": "Create Jira Issue per REST",
    "components": [{"name": "Xampl"}],
    "description": "Creating issue with project key & issue type 
                    using the REST API",
    "issuetype": { "name": "Test" },
    "customfield_10228":{
      "steps":[
        { "index":1,  
          "fields":{ "action":"Step 1", 
                     "data":"input Data 1", 
                     "expected result":"Excepted result 1"} },
        { "index":2, 
          "fields":{ "action":"Step 2", 
                     "data":"input Data 2", 
                     "expected result":"Excepted result 2" } },
        { "index":3, 
          "fields":{ "action":"Step 4", 
                     "data":"input Data 3", 
                     "expected result":"Excepted result 3" } }
      ]
    }
  }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.