How can we retrieve the preview URL (or attachment-id) for PDF attachments?
I'm trying to set up a custom component that makes a more prominent button for users to know they can preview an attached PDF in articles, but I'm having a hard time finding where the URL (or even the associated attachment-id value) can be retrieved via the Community APIs.
For example, I have created a TKB article with a PDF attachment, and there are two URLs associated with it:
- The title is hyperlinked with what I call the "preview URL" which looks something like this: https://community.example.com/t5/test-board/test-tkb-article/ta-p/33676?attachment-id=408
- The "download URL" associated with the download icon looks something like this: https://community.rsa.com/tenantid/attachments/tenantid/test-board/29/1/My_Random_PDF_Doc.pdf
I can retrieve the download URL just fine using a LiQL query such as: SELECT url FROM attachments WHERE message.id = '33676'
However, I can't seem to figure out where the attachment-id=408 field and value live in the APIs so I can recreate the preview URL.
The id of the attachment from the LiQL query above is 1 since it is attachment 1 of 1 in the message.
The same is observed with the API v1 call against the following endpoint: /messages/id/33676/uploads/attachments
If anyone has any thoughts or has come across this before then I'd love to get your suggestions. Thanks!
Looking at the documentation for the attachments collection the id field in the collection should indeed be a unique ID for that individual attachment. Instead, it seems to be the incremental identifier (first, second third...) for all attachments of a message. This looks like a LiQL bug and there wouldn't be any alternative to obtain that correct attachment-id. I suggest you create a case with Khoros to have this investigated.