Forum Academy Marketplace Showcase Pricing Features

Use external API to POST a thing to external website

Hi, I would appreciate any help on this. I am trying to figure out how to POST a thing/data table to an external space. If I use Python, the API call would be written as follows, and my current problem is to figure out how to work out the ‘content-length’: f’{len(data)}’ parameter. In the code below, it needs to make the file open first, and then take the length. Thanks in advance!

import requests

url = ‘{{workspace}}/file/{{directoryPath}}/{{fileName}}?overwrite={{false|true}}’

with open(’{{path_to_local_file}}’, ‘rb’) as file:
data =

headers = {
‘X-API-KEY’: ‘{{api_key}}’,
‘content-type’: ‘application/octet-stream’,
‘content-length’: f’{len(data)}’

response = requests.request(‘POST’, url, data=data, headers=headers, stream=True)