Upload map attachments - Fluid Topics - Latest

Integrate the Fluid Topics API

Category
Technical Notes
Audience
public
Version
Latest

The Add or update map attachments web service adds or updates attachments to publications based on the metadata defined in the call as follows:

/api/admin/khub/maps/attachments?metadata1=value1&...&metadataN=valueN

The following lines show an example of an Add or update map attachments web service implementation in Python where the file my_image.png is attached to the map with the originId of my_map:

import json
import requests

# order for my_image.png
my_image_order = {
    'id': 'my_image',
    'filename': 'my_image.png',
    'displayName': 'My Image'
    }

# Content of my_image.png file
with open('my_image.png', 'rb') as f:
    my_image_content = f.read()

# order.json part
    order = {
        "attachments": [my_image_order]
            }

# All the parts : order.json and my_image.png
parts = {
    'order.json': (
        'order.json', 
        json.dumps(order), 
        'application/json'
        ),
    my_image_order['filename']: (
        my_image_order['filename'], 
        my_image_content, 
        'image/png'
        )
    }

# Send
response = requests.put('https://demo/api/admin/khub/maps/attachments?ft:originId=my_map', files=parts)

print(response.status_code)
print(response.text)