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

This widget could not be displayed.

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.

This widget could not be displayed.

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?

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

55 views 1 0
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