open-api icon indicating copy to clipboard operation
open-api copied to clipboard

[BUG]: uploadListingImage returns inconsistent order error

Open carlosmartinez-dev opened this issue 2 years ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

Hi, I am connecting to some of your V3 APIs and when using this particular one https://developer.etsy.com/documentation/reference#operation/uploadListingImage  some times, not always, I get this error message:

{ "message": "Bad Request", "status": 400, "text": "{\"error\":\"The ListingImages for this Listing are in an inconsistent order.\"}\n", "method": "POST", "path": "/v3/application/shops/xxx/listings/yyy/images", "url": "https://openapi.etsy.com/v3/application/shops/xxx/listings/yyy/images", "params": { "name": "29d9f1a861449c641b5a0c5a5e50f2a5c886c3bf", "overwrite": true, "rank": 3 } }

I know the listing has a set of images and each one has a rank which determines its position where it appears, so I'd like to know the rules that Etsy determines that the listing-images are not in a consistent order so I can adjust my call and send the correct payload. Or reasons to get this particular error.

Steps to reproduce

  1. Make a call to https://openapi.etsy.com/v3/application/shops/{shop_id}/listings/{listing_id}/images
  2. Call details: method: "POST", path": "/v3/application/shops/xxx/listings/yyy/images" params: { "name": "29d9f1a861449c641b5a0c5a5e50f2a5c886c3bf", "overwrite": true, "rank": 3 }

Expected behavior

I expect to get a 201 response, but instead I get error: { "message": "Bad Request", "status": 400, "text": "{\"error\":\"The ListingImages for this Listing are in an inconsistent order.\"}\n", "method": "POST", "path": "/v3/application/shops/xxx/listings/yyy/images", "url": "https://openapi.etsy.com/v3/application/shops/xxx/listings/yyy/images", "params": { "name": "29d9f1a861449c641b5a0c5a5e50f2a5c886c3bf", "overwrite": true, "rank": 3 } }

Additional context

No response

carlosmartinez-dev avatar Apr 01 '22 20:04 carlosmartinez-dev

This happens sometimes when images are deleted. The easiest fix is to call updateListing and pass in the image_ids parameter with a comma delimited list of the images currently assigned to the image. This will force a re-numbering based on the order you put them in the comma delimited list. Then call the uploadListingImage endpoint and upload the new image. Our system is designed to force a self-correction on the numbering/ranking of the images but that sometimes takes a bit as it has to get queued up as an asynchronous job.

Also, I don't see an image or listing_image_id parameter in your input parameters above. You will need to pass in one of those two.

etsyachristensen avatar Apr 04 '22 14:04 etsyachristensen

Thanks @etsyachristensen , if all I want is to replace an image in a given position, will be enough to just update an image for a listing passing the rank value and also the overwrite property as true ?

carlosmartinez-dev avatar Apr 05 '22 16:04 carlosmartinez-dev

It should work that way yes. However, if the images are currently out of order for some reason (meaning there's a gap in the numbering) then it will throw that error. If you are still getting the error and the images are ranked properly let me know. The easiest way to know the rank is to call the getListingImages endpoint and look at the rank value in the returned array. If they are all numbered 1-5 (up to 5 - and not necessarily returned in order of rank) and there are no gaps, then we need to know the listing id and the listing image id you are trying to replace and the id you are trying to replace it with.

etsyachristensen avatar Apr 07 '22 15:04 etsyachristensen

I started seeing this recently on integration tests that previously had been going through, I updated so that I POST the images in rank order and that fixed it, however I still think its quite restrictive to have to do this from a client point of view.

FloppyChips avatar Jun 06 '22 09:06 FloppyChips