Python Image Asset Creation Issue

Hey, trying to push an image asset into contentful so I can use it in an entry. However, it keeps coming back to me with;
HTTP status code: 422
Message: Validation error

I’ve tried using this;
https://www.contentful.com/developers/docs/references/content-management-api/#/reference/assets/assets-collection/create-an-asset/console/python

But, then it gives me an issue and says I need a url field instead. So I replaced ‘upload’ with ‘url’. Still getting the 422 error though. Here’s my code;

        # Create an Asset:
        asset_id = None  # Use `None` if you want the API to autogenerate the ID.
        asset = client.assets(siete_space_id, environment_id).create(asset_id, {
            'fields': {
                'title': {
                    'en-US': row['Product']
                },
                'file': {
                    'en-US': { 
                        'contentType': 'image/jpeg',
                        'fileName': row['Product'] + '.jpg',
                        'url': product_info.iloc[0]['Image_Url']
                    }
                }
            }
        })

        try:
            # Update an Asset:
            asset.title = row['Product']
            asset.save()
            # Publish asset
            asset.publish()
        except Exception as e:
            print(e)

Hey @morgunpavlo

You first need to create an Upload (refer to this - https://www.contentful.com/developers/docs/references/content-management-api/#/reference/uploads)

Once the upload is successful, you then need to use the JSON from that Upload (using something like upload.to_link().to_json in the uploadFrom field of an Asset. This will like the file to the asset.

I hope this was helpful.