Error on trying to create a remote link for an issue

Ian Miller June 29, 2016

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

1 vote
Answer accepted
Petar Petrov (Appfire)
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.
June 30, 2016

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.

0 votes
Ian Miller June 30, 2016

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).

Petar Petrov (Appfire)
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.
June 30, 2016

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?

Ian Miller June 30, 2016

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?

0 votes
Petar Petrov (Appfire)
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.
June 29, 2016

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?

Suggest an answer

Log in or Sign up to answer