0

i want to create an issue in JIRA by using the REST API provided by JIRA. i am able to create a simple issue,

using this :

   http://localhost:8080/rest/api/latest/issue

and data as follows:

   {"fields":{"project":{"key": "TES"},"summary":"user name not showing validation message","description":"Hi validation is missing from user name","issuetype": {"name": "Bug"},"reporter":{"name":"BruceWayne"}  }}

this is running fine.

now i want to add 3 custom fields while creating an issue. The custom fields are Authorname, AuthorTag,AuthorID. how can i do this in rest api. what should i add in my data.

My sample data is as follows:-

   {"fields":{"project":{"key": "TES"},"summary":"my bugs 5","description":"Hi","issuetype": {"name": "Bug"},
       "customfield_10000":"[email protected]",
       "customfield_10100":{"value":"abc"},
       "reporter":{"name":"amit"},
       "components": [{
                 "add" : {"name" : "abc"}
                }],"priority": {
 "id": "1"
  }

      }}

i want to use the names specified for customfields rather than customfield_XXXXX .

One way i think of is to hit the API after creating a simple issue ( using another API hit to get meta data as follows)

 http://localhost:8080/rest/api/latest/issue/tes-79?expand=editmeta

and then do json parsing and again issue a put command to update the fields in same issue

but i was looking for a way to do it in single API hit (while creating an issue)

2 Answers 2

1

It should be just like setting any other field, but you have to use the field name "customfield_NNNNN" instead

Sign up to request clarification or add additional context in comments.

1 Comment

i used the same . i have included my sample data in the question. i got it working but now i have a new concern my "Customfield_10100" is named as "AuthorName" and customfield_10000 is "bgEmail" in JIRA. so is there any way to specify that in my data. or do i have to hardcode them always as customfield_nnnnnn. one way is to again hit the API and get meta data and do a lot of json processing.
0

I know that it is very late to answer this question, but then might help others if not the OP at this time of writing.

If you're in doubt about the create, then you could do something like this - Try a GET on an issue that you would rather create manually with the new parameters as well and then based on the output of the same you could then decide to update it with the new parameters with the new name or the old-fashioned customfield_xxx field.

Try a GET like this on cURL

curl -D- -u fred:fred -X GET -H "Content-Type: application/json" https://jira.fred.com/rest/api/2/issue/FRD-88651

Then you could possibly do a POST like how you've done earlier:

http://localhost:8080/rest/api/latest/issue

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.