Http 400, errors for Direct upload


{‘errors’: [{‘status’: ‘400’, ‘title’: ‘Validation Error’, ‘detail’: ‘“value” must be of type


def upload_asset(self, path):   #png file
    headers = {
    "x-api-key": myapikey}
    with open(path, 'rb') as f:
        data =
        res = requests.request(
            headers=headers, data=data

Ive tried many more modifications(headers, request), but I keep getting error messages. Kindly suggest.

It looks like you are sending the file data body to the endpoint which will give you this error.

Uploading files is a two step process. The first step is to request a signed URL, the signed URL is where you upload (PUT) the file to.

So in your code above you will need to remove the data payload and only POST to the endpoint with the headers.

You should then receive a response with a URL that looks similar to:

Then use that URL in a new request using PUT, the returned signed URL and the payload. You should not send any headers or the x-api-key as you are using the signed URL which has credentials built in to it.

I am not sure exactly how you would do this with Python but the cURL request is like this:

curl -X PUT -T image.png

Here is the full documentation to upload directly and the two step process: Ingest Files with the Ingest API | Shotstack Documentation.

Right I did see it, thats what confused me, because API examples use a POST.

Thanks for your fast input.

Will try and make this clearer in the docs so it is easier to follow.

1 Like