Python request for referral API

Hello!

I am interested in using the API, and I started with the referral API:

https://i.materialise.com/api/docs/3d-print-lab-connection-api

I would like to do this using Python’s request, but I couldn’t find an example on github.

This is what I have:

from requests_toolbelt.multipart.encoder import MultipartEncoder
import requests

API = my_api
ID = my_id

Link = ‘https://drive.google.com/u/0/uc?id=1s2sNd3lKZ2UFRgeJGnGq_pCTvENOExh-&export=download

m = MultipartEncoder(
fields={‘useAjax’:‘True’, ‘forceEmbedding’: ‘False’,‘pluging’:ID,
‘fileUrl’: Link}
)

headers = {‘Content-Type’: m.content_type,
‘User-agent’: ‘Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/64.0.3282.167 Chrome/64.0.3282.167 Safari/537.36’,
‘Host’:‘imatsandbox.materialise.net’,
‘Origin’:‘https://imatsandbox.materialise.net/upload’,
‘Connection’:‘keep-alive’
}

resp = requests.post(‘https://imatsandbox.materialise.net/upload’, data=m,
headers=headers, allow_redirects=False)

print(resp.url)

As a result, however, I get an error URL.

I would greatly appreciate it if somebody could point me in the right direction. Ideally, I would like to have a file stream rather than having to upload it first to Google Drive.

Thanks!