New Shopify Certification now available: Liquid Storefronts for Theme Developers

Shopify API Upload Image: HTTPError: Response code 422 (Unprocessable Entity) using Base64 encoding.

Solved
blanklob
Shopify Partner
4 1 0

I'm trying to upload an image via the Shopify REST Admin API Product Image ressource but I always get this error

Also, the image is jpg 2048x2048 100kb compressed using Mozjpeg algorithme, the attachment URL has only the binary encoding it doesn't have the data:base... attribute at the beginning, I tried everything but I always get that error I changed sizes formats ect..

 

code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 1667651339658,
    socket: 1667651339658,
    lookup: 1667651339659,
    connect: 1667651339708,
    secureConnect: 1667651339731,
    upload: 1667651339843,
    response: 1667651340567,
    end: 1667651340569,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 0,
      dns: 1,
      tcp: 49,
      tls: 23,
      request: 112,
      firstByte: 724,
      download: 2,
      total: 911
    }
  }
}

 This is so frustrating because I have generated the image to my file system and it works also the base64 code that was used in the attachment param was valid and verified checked it in the browser, what Am I missing?

A Shopify Developer building in public Shopify themes from scratch. I love what I do and I’m willing to share it ❤️
Accepted Solution (1)
blanklob
Shopify Partner
4 1 0

This is an accepted solution.

Haha it worked I can't believe I misspelled attachment to attachement in my params even though I'm using Typescript.

A Shopify Developer building in public Shopify themes from scratch. I love what I do and I’m willing to share it ❤️

View solution in original post

Reply 1 (1)
blanklob
Shopify Partner
4 1 0

This is an accepted solution.

Haha it worked I can't believe I misspelled attachment to attachement in my params even though I'm using Typescript.

A Shopify Developer building in public Shopify themes from scratch. I love what I do and I’m willing to share it ❤️