Forum Discussion

jeffshurtliff's avatar
4 years ago

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:

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.

2 Replies

  • 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.

  • Thanks Claudius.  I've just opened a support case (#00358831) for this and will report back in this thread with what I find out.