Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

JIRA Rest API create ticket using php form not setting priority and other custom fields

Sumithra Sudhir July 27, 2015

Its throwing an error "priority":"Could not find valid 'id' or 'name' in priority object.

I need to retrieve the form values and create tickets in JIRA on submit. I am able to retrieve the description field from the form, but not the priority and other custom fields. See below.

 I have referred to the API, still no luck.

 Is this even a valid way of setting the form values.

    $new_issue = array(

        'fields' => array(

        'project' => array('key' => 'somevalue'),

        'summary' => somevalue',

        'description' => $_POST['description'],

        'priority' => $_POST['priority'],

        'issuetype' => array('name' => 'somevalue'),

      

        )

    );

 

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Volodymyr Krupach
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.
July 27, 2015

The JSON sample is on JIRA REST API page near /rest/api/2/issue POST,  https://docs.atlassian.com/jira/REST/latest:

{
    "update": {
        "worklog": [
            {
                "add": {
                    "started": "2011-07-05T11:05:00.000+0000",
                    "timeSpent": "60m"
                }
            }
        ]
    },
    "fields": {
        "project": {
            "id": "10000"
        },
        "summary": "something's wrong",
        "issuetype": {
            "id": "10000"
        },
        "assignee": {
            "name": "homer"
        },
        "reporter": {
            "name": "smithers"
        },
        "priority": {
            "id": "20000"
        },
        "labels": [
            "bugfix",
            "blitz_test"
        ],
        "timetracking": {
            "originalEstimate": "10",
            "remainingEstimate": "5"
        },
        "security": {
            "id": "10000"
        },
        "versions": [
            {
                "id": "10000"
            }
        ],
        "environment": "environment",
        "description": "description",
        "duedate": "2011-03-11",
        "fixVersions": [
            {
                "id": "10001"
            }
        ],
        "components": [
            {
                "id": "10000"
            }
        ],
        "customfield_60000": "jira-developers",
        "customfield_20000": "06/Jul/11 3:25 PM",
        "customfield_80000": {
            "value": "red"
        },
        "customfield_40000": "this is a text field",
        "customfield_30000": [
            "10000",
            "10002"
        ],
        "customfield_70000": [
            "jira-administrators",
            "jira-users"
        ],
        "customfield_50000": "this is a text area. big text.",
        "customfield_10000": "09/Jun/81"
    }
}

If mean PHP sample fro creating JSON, then you need to consult some PHP resources.

0 votes
Sumithra Sudhir July 27, 2015

thank you so much. I am stuck at retrieving the html form value and writing to the array before creating JSON.

0 votes
Sumithra Sudhir July 27, 2015

Thank you for responding. I am new to writing json code and unclear how to use this. Do you have a full code example that you can post here, please? 

0 votes
Volodymyr Krupach
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.
July 27, 2015

As I understand you use /rest/api/2/issue POST JIRA REST method.

The priority JSON portion should look like:

priority: {"name" : "High"}

Or if you pass id:

priority: {"id" : 123}

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events