contentful-management.py icon indicating copy to clipboard operation
contentful-management.py copied to clipboard

UnprocessableEntityError while publishing an Asset!

Open neenuj opened this issue 4 years ago • 1 comments

Hello,

When I tried to publish an asset with file attributes I got a "UnprocessableEntityError" error. Below is the code which I used to publish the asset. The complete error message can be found below as well. Please let me know how this issue can be addressed.

CODE

file_attributes = { 'fields': { 'file': { 'en-US': { 'fileName': 'products.jpg', 'contentType': 'image/jpg', 'url': 'https://cdn.shopify.com/s/files/1/2195/2237/products/P1010793_1000x.jpg?v=1594381279'}}}}

asset = client.assets(spaceid, envid).create('products007', file_attributes) asset.publish()

ERROR

UnprocessableEntityError: HTTP status code: 422 Message: Validation error Details: * Name: hasHostname - Path: '['fields', 'file', 'en-US', 'url']' - Value: 'https://cdn.shopify.com/s/files/1/2195/2237/products/P1010793_1000x.jpg?v=1594381279' Request ID: c72de457c1a85922aa292fce2d23ae67

neenuj avatar Feb 12 '21 11:02 neenuj

I got the same error... I avoid using one sleep(1) between process() and publish()

asset.process()
sleep(1)
asset.reload().publish()