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?
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.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.