Add or update attachments - Fluid Topics - Latest

Fluid Topics API Reference Guide

Category
Reference Guides
Audience
public
Version
Latest

This web service adds (if new) or updates (if existing) attachments based on metadata selection.

Method Endpoint
PUT
/api/admin/khub/documents/attachments?metadata1=value1&...&metadataN=valueN
Query string parameter Type Required? Description
metadata=value String Yes Any metadata key-value couple defining the documents to add or update.

For example, /api/admin/khub/documents/attachments?Version=Latest adds the same attachment(s) to all documents with the Version=Latest metadata key.

Use an ampersand (&) to make the request more precise by adding metadata keys. For example: /api/admin/khub/documents/attachments?Category=Example&Version=Latest

To target a single document, use the document's ft:originId value.

To add or update an attachment, the web service call requires a multipart/form-data request body where the different parts consist in:

  • Sending an order to the Fluid Topics server to attach a file to the matched publications.

    This requires the upload of an order.json file containing the attachment's metadata.

  • Uploading the attachment itself.

Example

The following code block is an example of order.json file for attaching a document:

{
  "attachments": [
    {
      "id": "my_attachment",
      "filename": "oleandor.jpeg",
      "displayName": "Oleandor Company Logo"
    }
  ]
}
Field Type Description
id String The optional value used to identify the attachment (uses the filename by default).
filename String The file name of the attachment.
displayName String The optional display name of the attachment (uses filename by default).

The web service is sending asynchronous requests. It may take a while for the attachment to upload, and for the publication to update.

Updating existing attachments requires calling the same web service with the same id (or filename if the id has not been specified), and by modifying the other properties (displayName, content-type, attachment content, or even the filename if an id has been specified).

Return code Description
202 ACCEPTED The update instruction was sent to the Fluid Topics processing pipeline.
400 BAD REQUEST Invalid query.