I am trying to add a preview of an attached file to a page through confluence API with view file macro. It works fine but the title of the preview is some random Id. When I add a preview through web it shows the file name as the title of the attachment preview. I can't find the documentation to set this preview title. The left one in the image is added through API and the right one through web.
This is the call to upload the attachment
curl -v -S --header 'Authorization: Basic ${token}' -X POST -H "X-Atlassian-Token: no-check" -F "file=@filePath" https://abc.atlassian.net/wiki/rest/api/content/${PageId}/child/attachment
This is the page content
<p class="media-group">
<ac:structured-macro ac:name="view-file" ac:schema-version="1" ac:macro-id="8470d36e-7035-4ee4-9ea5-d8a3fc87b843">
<ac:parameter ac:name="name">
<ri:attachment ri:filename="' + fileName + '" ri:version-at-save="1" />
</ac:parameter>
</ac:structured-macro>
</p>
This is the JSON body
{
"type": "page",
"title": "pageTitle",
"version": {
"number": 2
},
"body": {
"storage": {
"value": "${content}",
"representation": "storage"
}
}
}
This is the call to the API to update page content
curl -H 'Authorization: Basic ${token}' -H 'Content-Type: application/json' -X PUT -d'@requestBody' https://abc.atlassian.net/wiki/rest/api/content/${PageId}?expand=body.storage
Hi @M Umer Welcome to the Atlassian Community!
Are you passing below parameter in your json body ? it will update title for the attachment and might solve your problem.
"title": "<string>"
Please share the json body if possible and the endpoint you are using.
Updated my question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thank you, can you please confirm if this is for Cloud or Server, because i am unable to find view-file macro on cloud.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.