Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
  • Community
  • Answers Developer Questions
  • Questions
  • [Jira CREATE issue API ERROR:] Can not instantiate value of type [simple type, class com.atlassian.jira.rest.v2.issue.IssueUpdateBean] from JSON String; no single-String constructor/factory method"

[Jira CREATE issue API ERROR:] Can not instantiate value of type [simple type, class com.atlassian.jira.rest.v2.issue.IssueUpdateBean] from JSON String; no single-String constructor/factory method"

Krassi Hristova April 19, 2016

Hey guys,

I'm using the JIRA REST API to create a single JIRA sub-task issue via a json blob, but am running into a weird undocumented error. Is someone able to help?

ERROR:

The request errors with a 400:

"errorMessages":["Can not instantiate value of type [simple type, class com.atlassian.jira.rest.v2.issue.IssueUpdateBean] from JSON String; no single-String constructor/factory method"]}

I've checked the JSON and it is valid, the auth headers in the request are working without issue. I tired utf-8 encoding and still no go. The user has explicit permissions to view & create issues in the given project as well as to admin that project as well.

I also called the view Issue API and tried passing that exact JSON (without the "expand", "id", "self" and "key" fields that precede  "fields") to the /create/ API - but still got this error.

Does anyone have any ideas?

Here're the details:

  • API - https://<HOST>/rest/api/2/issue/ 
  • Request

    url = CREATE_URL
    	header = {'Content Type': 'application/json'}
    	#set the user name and password values
    	user = JIRA_USER
    	
    	# block for setting the JIRA password
    		(omitted)
    
    	#setting the file from which to read the JSON which will be passed into the JIRA API
    	with open('1_ticket.json', "rb") as output:
    		payload = output.read()
    
    	#make the authenticated request to the JIRA API
    	r = requests.post(url, json=payload.encode('utf-8'), headers=header, auth=HTTPBasicAuth(user, password))
    	print "HERE's the JSON RESPONSE ", r.text
  • JSON BLOB
{
  "fields": {
    "parent": {
      "id": "TEST-115"
    },
    "summary": "TEST MILESTONE",
    "issuetype": {
      "id": "12354",
      "subtask": true
    },
    "description": "h3. BLA BLA BLA",
    "project": {
      "id": "1111"
    },
    "reporter": {
      "name": "name"
    },
    "assignee": {
      "name": "name"
    },
    "status": {
      "id": "10000"
      },
    "customfield_12501": {
      "id": "12100"
    }
  }
}


 

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Krassi Hristova April 19, 2016

Okay, I have found the issue - it has to do with how the payload var is being created.

When I changed the code to use one of the JSON methods for loading a file to the following, I was able to create the issue via the API without a problem:

payload = json.loads(output.read())
Stephen Welch July 13, 2016

So what did this other method do to the payload that wasn't being done before? I'm using a different programming language and have the same issue. Is is a JSON escaping issue???

Like # people like this
Raghukrishna Hegde August 2, 2017

Test

TAGS
AUG Leaders

Atlassian Community Events