Field doesn't match pattern, when using Jira REST API to create issue

Hy Nguyen December 20, 2018

Hi,

I'm having a JIRA instance (version 7.13) running at localhost:8080. It has a project with key "JUL". I'm following the Jira's REST API tutorial here to create an issue remotely.

This is my request (GET) body:

http://localhost:8080/rest/api/2/issue/createmeta?projectKeys=JUL&issuetypeNames=Bug&expand=projects.issuetypes.fields
&data={
    "fields": {
       "project":
       {
          "key": "JUL"
       },
       "summary": "REST ye merry gentlemen.",
       "description": "Creating of an issue using project keys and issue type names using the REST API",
       "issuetype": {
          "name": "Bug"
       }
   }
}

Some how I don't get the expected result in the tutorial but this error response:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<status>
    <status-code>500</status-code>
    <message>key &lt;fields
&gt; doesn't match pattern</message>
    <stack-trace>java.lang.RuntimeException: key &lt;fields
&gt; doesn't match pattern&#xD;
    at com.atlassian.plugins.rest.common.expand.parameter.DefaultExpandParameter$ExpandKey.from(DefaultExpandParameter.java:122)&#xD;
    at com.atlassian.plugins.rest.common.expand.parameter.DefaultExpandParameter$ExpandKey.access$000(DefaultExpandParameter.java:100)&#xD;
    at com.atlassian.plugins.rest.common.expand.parameter.DefaultExpandParameter.appendParam(DefaultExpandParameter.java:67)&#xD;
    at ......

The error log is exceeded 2000 chars, basically I think that may be there was some problem with my <fields> JSON structure, may be the document was not up-to-date, but I don't know where to find the correct structure for that. Could you please give me some tips on this, thank you.

1 answer

1 vote
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 22, 2018

Hi @Hy Nguyen

The method you are calling

http://localhost:8080/rest/api/2/issue/createmeta

returns meta data about the project and IssueTypes available for use. It isn't a method for creating issues so won't accept your new issue data.

"The fields that can be set on create, in either the fields parameter or the update parameter can be determined using the /rest/api/2/issue/createmetaresource. If a field is not configured to appear on the create screen, then it will not be in the createmeta, and a field validation error will occur if it is submitted."

I recommend installing REST API browser in a dev copy of JIRA for exploring these options.

To create an issue use POST method to

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

with the new issue JSON in the request body

You will need to use the internal id's for project and issue type as returned from the createmeta call.

See examples here

https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events