Error on trying to create a remote link for an issue

I have been trying to create a remote link for an issue using the following endpoint.

/rest/api/2/issue/<ISSUE_KEY>/remotelink

The screencaps below shows the POST request logic.

Screen Shot 2016-06-29 at 7.00.16 PM.png

Screen Shot 2016-06-29 at 7.00.10 PM.png

The parameters in the post request are as follows:

full_url = 'https://<domain>.atlassian.net/rest/api/2/issue/PTPL-34/remotelink'
data = {"object": { "title": "Asana", "url": "https://asana.com/0/1234/1234" }}



This is the error that I get back from the API when the POST request is made (via requests):

{
	u'errorMessages': [u"Unexpected character ('o' (code 111)): expected a valid  value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.apache.catalina.connector.CoyoteInputStream@180652f; line: 1, column: 2]"]
}

Any idea what I may be doing incorrectly?

3 answers

1 accepted

Accepted Answer
1 vote

OK, as I suspected your Python client lib is form-encoding your data, rather than sending it as JSON. Try this:

requests.post(full_url, headers=headers, json=data)

See the documentation for more information and examples.

The problem is that the server does not understand the data you are sending. This may be due to various reasons - to understand why you need to trace the actual POST request being sent. One reason could be missing Content-Length header, another could be improperly constructed JSON data. What is the client API you are using?

I am using the REST client (JIRA REST API v2). My guess is that I'm not properly structuring the data - I'll explore more in depth today. The documentation isn't explicit about how the params should be structured (https://docs.atlassian.com/jira/REST/latest/#api/2/issue-createOrUpdateRemoteIssueLink).

Sorry if my question was not clear - which is the client library you are using for doing the post request? Does it add the Content-Length header automatically, does it need JSON data to be pre-processed in some manner?

Oh, my apologies. I'm using the python "requests" client (version 2.5.3).

Here are the headers included in the request:

{
	'X-AUSERNAME': 'ian.miller', 
	'X-AREQUESTID': '385x18736x1', 
	'X-Content-Type-Options': 'nosniff', 
	'Transfer-Encoding': 'chunked', 
	'Set-Cookie': '..........',
	'X-Seraph-LoginReason': 'OUT, OK', 
	'X-ASESSIONID': '12wjbma', 
	'Server': 'nginx', 
	'Connection': 'keep-alive', 
	'X-ATENANT-ID': 'percolate.atlassian.net', 
	'Cache-Control': 'no-cache, no-store, no-transform', 
	'Date': 'Thu, 30 Jun 2016 13:25:28 GMT', 
	'Content-Type': 'application/json;charset=UTF-8', 
	'X-ASEN': 'SEN-6393989'
}

Don't see a Content-Length header - I can add this in manually. What would I need to specify as the value for the 'Content-Length' header?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 16, 2018 in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

77 views 0 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you