Processing asset is failing; cannot publish

I am trying to migrate assets from one environment to another in the same space.

I’m using the createAssetWithId method from the Contentful Management API to migrate the asset with its ID from the source environment to the target environment.

However, I’m getting this error when publishing:

ValidationFailed: {
  "status": 422,
  "statusText": "Unprocessable Entity",
  "message": "Validation error",
  "details": {
    "errors": [
        "name": "badFileUrl",
        "path": [
        "details": "Invalid asset URL"
  "request": {
    "url": "assets/5KRzAvo7a4xq7iuLuuQ9B3/published",
    "headers": {
      "Accept": "application/json, text/plain, */*",
      "Content-Type": "application/",
      "X-Contentful-User-Agent": "sdk contentful-management.js/5.28.0; platform node.js/v10.16.2; os Windows/10.0.18362;",
      "Authorization": "Bearer ...fbbFQ",
      "user-agent": "node.js/v10.16.2",
      "Accept-Encoding": "gzip",
      "X-Contentful-Version": 2
    "method": "put",
    "payloadData": null
  "requestId": "f77f2c74115b8bf071fd58455f26bd27"

This is the code for creating and processing the asset. The publishing part comes after that.

await cmaClient.getSpace(spaceId)
        .then(async (space) => await space.getEnvironment(environmentId))
        .then(async (environment) => await environment.createAssetWithId(, { fields: assetItem.fields }))
        .then(async (asset) => await asset.processForAllLocales({ processingCheckWait: 5000, processingCheckRetries: 25 }))
        .then(customLogger.success(`Asset '${}' has been created.`))

assetItem.fields has the following properties:

{ title: { 'en-US': 'image title' },
  description: { 'en-US': ' ' },
   { 'en-US':
      { fileName: '',
        contentType: 'image/jpeg',
         '<space_id>/<asset_id>/2hj84bce4dedcfc78654b98hhhr452t7/image.jpg' } } }

The asset gets created but the image doesn’t appear and doesn’t get processed and therefore published.