Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get the id of an attachment?

J D
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.
November 3, 2014

Where can i get the if of an attachment from? I didnt find it in the attachement section.

 

Thanks

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Stephen Deutsch
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.
November 3, 2014

If you can use the REST API, then you can get the ID of an attachment.  There are three different methods you could use:

  1. /rest/searchv3/1.0/search?queryString={filename}&type=attachment

  2. /rest/prototype/1/content/{pageId}/attachments

  3. /rest/api/content/{pageId}/child/attachment

You could search for the filename using the first one, or you could use the page ID for the second and third (with the third one, the id is prefixed with "att".

I would recommend using the second one, as it is the one that will be compatible with the most versions.  You could either use the REST API browser available from the marketplace, or you could paste this url in your browser:

http://<your confluence site>/<contextpath (if you have one)>/rest/prototype/1/content/<pageId>/attachments?os_username=<your username>&os_password=<your password>

Just fill in the blanks with the required information and you will see the IDs for all attachments attached to that page.

 

J D
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.
November 3, 2014

REST API Browser > api/content({id}/child(attachment > id = pagedid You get all attachments. Thanks for that hint :)

0 votes
Jaime S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 3, 2014

Hi, there.

 

I think you can get that by going to the attachments page, hovering your pointer over the attachment's name and checking the URL. I think the ID is the number 'attachments', like: https://myconfluence.com/download/attachments/11111111/attachment.png?api=v2

I hope that was what you were asking.

 

Kind regards.

Jaime Kirch da Silveira.

J D
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.
November 3, 2014

Okay thanks i will try that and give you response.

Stephen Deutsch
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.
November 3, 2014

Actually that is the ID of the page that the attachment is attached to.

J D
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.
November 3, 2014

Yep, that wasn't it.

Alexander Sopov April 20, 2017

The attachment has a data-attribute called "data-linked-resource-id". I'm not 100% sure, but I think that is it. I'm looking for an answer to this question, too and I'll try that out now

Like Julien Teisseire likes this
TAGS
AUG Leaders

Atlassian Community Events