I have previously developed code to create an issue to Jira using API.
It was developed using Jira API, C#, JSON and HttpWebRequest.
A new requirement to include 2 custom fields has caused this question. The fields are both of type Text Field (single line). When I include the custom fields in my JSON data line, I get "The remote server returned an error: (400) Bad Request." error from the server.
My assumption is that my logic using HttpWebRequest in C# is sound, because I can create an issue without including the custom fields without error.
Please review the below JSON data line and tell me what I have done wrong, or whether this can be done using Jira API.
{
"fields":
{
"project":
{
"key":"TP"
},
"summary":"Test using custom fields",
"description":"Test creating issue with 2 custom fields.",
"issuetype":
{
"name":"Task"
},
"customfield_10901": "Test 2",
"customfield_10902": "Test 1"
}
}
Thank you.
I found a work around by using update instead of create. Once a issue is created I then update custom fields. This works.
This allows me to move forward, but if anyone can help me with creating a new issue with custom fields, I would be interested in understanding what I have missed.
Thank you.
Not exactly in C# but I usually first create a bash file named bashInsert.bat to call my json script, the content of the .bat file is something like this:
curl -D- -u user:password -X POST --data @/Users/MyUser/Documents/testInsert.json -H "Content-Type: application/json" https://jira.domain.com/rest/api/2/issue/
-------------------------------------------------------------
Then the my testInsert.json that I will be calling seems like the following:
{
"fields": {
"project":
{
"key": "MXS000000"
},
"summary": "As user I would like to test the OK button",
"description": "Test the OK but and see what happens",
"issuetype": {
"name": "Test"
}
}
}
I reviewed what you have written and seems to be right, I just be checking about the permissions on your customfields?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @David Wells,
Please confirm these two fields are on the create screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Both are on the create screen.
I have also tried to update an existing issue with these fields and get the same error.
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.