Hi,
I tried to attach a text file to an asset using the assets REST API but for some reason I can't get the request right.
I took the request headers from this documentation: https://insight-javadoc.riada.io/assets-rest/#attachments_object__objectid__post because this other one doesn't describe the attachments endpoint although the endpoint exists https://developer.atlassian.com/cloud/assets/rest/api-group-aql/
My request:
POST /jsm/assets/workspace/{workspaceId}/v1/attachments/object/{objectId} HTTP/1.1
X-Atlassian-Token: no-check
Cache-Control: no-cache
Authorization: Basic XXXXXXXXXXXX
Postman-Token: XXXXXXXXXXX
Host: api.atlassian.com
Content-Type: multipart/form-data; boundary=--------------------------781657821705825765126353
----------------------------781657821705825765126353
Content-Disposition: form-data; name="file"; filename="fan.txt"
Content-Type: text/plain
<fan.txt>
----------------------------781657821705825765126353--
Here is the response I get:
HTTP/1.1 415 Unsupported Media Type
Date: Fri, 06 Jan 2023 13:40:32 GMT
Content-Type: application/json
Content-Length: 65
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Expires: 0
Pragma: no-cache
X-Computation-Group-Id: 4700a49f-dc08-455d-9e7f-477fc1dc97bc
X-Monolith-Alive: true
X-Pod-Type: standard
Vary: Accept-Encoding
Server: AtlassianEdge
X-Trace-Id: a144c572810f56b9
X-Frame-Options: SameOrigin
Expect-Ct: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/stargate2", max-age=86400
X-Content-Type-Options: nosniff
X-Xss-Protection: 1; mode=block
Atl-Traceid: a144c572810f56b9
Report-To: {"endpoints": [{"url": "https://dz8aopenkvv6s.cloudfront.net"}], "group": "endpoint-1", "include_subdomains": true, "max_age": 600}
Nel: {"failure_fraction": 0.001, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}
Strict-Transport-Security: max-age=63072000; preload
{"errorMessages":["HTTP 415 Unsupported Media Type"],"errors":{}}
The request for getting the existing attachments from an asset works fine.
GET /jsm/assets/workspace/{workspaceId}/v1/attachments/object/{objectId} HTTP/1.1
Authorization: Basic XXXXXXXXXXXXXXXXXX
Postman-Token: XXXXXXXXXXXXXXX
Host: api.atlassian.com
When I tried to add the same file to a jira issue instead of an asset the request worked.
POST /rest/api/2/issue/{issueKey}/attachments HTTP/1.1
X-Atlassian-Token: no-check
Authorization: Basic XXXXXXXXXXXXXXXXXXX
Postman-Token: XXXXXXXXXX
Host: your-domain.atlassian.net
Content-Type: multipart/form-data; boundary=--------------------------787394739551725715867800
Cookie: atlassian.xsrf.token=XXXXXXXXXXXXXXXXX
----------------------------787394739551725715867800
Content-Disposition: form-data; name="file"; filename="fan.txt"
Content-Type: text/plain
<fan.txt>
----------------------------787394739551725715867800--
Please help me with some answers to the following questions:
Thank you
Hi @CristinaVo I'm also looking for a way to attach documents to objects on Jira Asset (Ex Insight) too.
Currently it is not possible with the official and documented APIs.
There is an open issue in Atlassian here: https://jira.atlassian.com/browse/JSDCLOUD-10454
Gabriele
Hi @Gabriele Cecco, I eventually found out about about this issue from the Atlassian support team, and I also voted it.
Thank you very much for your answer,
Cristina
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.