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

[BUG] Calculated shipping profile is not inferring units

Open yovasx2 opened this issue 2 years ago • 6 comments

Describe the bug When u use create/update endpoint with a fixed shipping profile, u can pass only the amounts for weight and dimensions, the units are inferred if u send null values or omit item_weight_unit, item_dimensions_unit. Otherwise calculated shipping profile required these values, but there is no endpoint to obtain such information, especially because if u start mixing units (metric) in a shop based in us (imperial) then the etsy UI shows blanks with imperial labels

To Reproduce Send a payload to create/update endpoints omitting units it works for fixed shipping profiles Send a payload to create/update endpoints omitting units it won't work for calculated shipping profiles:

 "error": "Could not set a calculated shipping profile to the listing.  The listing is missing 'item_weight', 'item_length', 'item_width', 'item_height', 'item_weight_unit' or 'item_dimensions_unit'."

Expected behavior Units inference since there is no endpoint to obtain that info and the Etsy UI cannot display units different from the country where the shop is based

Additional context Add any other context about the problem here.

yovasx2 avatar Dec 23 '21 23:12 yovasx2

@yovasx2 I'm not entirely sure I understand the issue here. If you are working with a calculated shipping profile, all of those fields are required: 'item_weight', 'item_length', 'item_width', 'item_height', 'item_weight_unit' and 'item_dimensions_unit'

The error is sort of a catch-all saying that you left out at least one of the fields. If you didn't specify units it will fail with that message.

Is the issue simply that you don't know what unit the shop is in so you can't specify the units?

etsyachristensen avatar Jan 11 '22 17:01 etsyachristensen

@yovasx2 As a quick follow-up, in our system, if the shop's country is in the US, it uses imperial values for weights and dimensions. Otherwise it uses metric. With that knowledge, if you have the shop object already (by querying getShop) you should have the shop_location_country_iso value so you can determine the correct units and always include them.

etsyachristensen avatar Jan 11 '22 21:01 etsyachristensen

When u create a product using a fixed shipping profile and omit the units in the payload the response contains the units defined by etsy automatically, this behavior would be really useful when u use calculated profiles instead, current behavior is API is not inferring them it's complaining about missing fields as u described above (this is not happening with fixed profiles)

yovasx2 avatar Feb 03 '22 18:02 yovasx2

@yovasx2 you are correct. The system will not assume values for you on calculated profile. We are working on a change now that will leave the dimensions, weight and units null on fixed shipping profiles as they should be. The only reason it's not complaining about missing units is because it's defaulting and not leaving them null. We can not modify the calculated shipping profile behavior. It will require the dimensions, weight and units in order to calculate the shipping.

etsyachristensen avatar Feb 03 '22 19:02 etsyachristensen

is there an update on this?

yovasx2 avatar May 12 '22 17:05 yovasx2

@yovasx2 Can you check on this? With the recent change to the PATCH endpoint for updateListing, this shouldn't be a problem anymore.

etsyachristensen avatar Aug 08 '22 15:08 etsyachristensen

it's the same, while using a fixed profile if u omit or send null the units are taken correctly, as oz and in:

curl --location --request POST 'https://openapi.etsy.com/v3/application/shops/18976342/listings' \
--header 'Content-Type: application/json' \
--data-raw '{
    "title":"draft",
    "description":"draft",
    "quantity":1,
    "price":1,
    "who_made":"i_did",
    "when_made":"2020_2021",
    "is_supply":"false",
    "taxonomy_id":66,
    "production_partner_ids":[],
    "item_weight": 2,
    "item_length": 2,
    "item_width": 2,
    "item_height": 2,
    "shipping_profile_id": 172246891939
}'


curl --location --request POST 'https://openapi.etsy.com/v3/application/shops/18976342/listings' \
--header 'Content-Type: application/json' \
--data-raw '{
    "title":"draft",
    "description":"draft",
    "quantity":1,
    "price":1,
    "who_made":"i_did",
    "when_made":"2020_2021",
    "is_supply":"false",
    "taxonomy_id":66,
    "production_partner_ids":[],
    "item_weight": 2,
    "item_length": 2,
    "item_width": 2,
    "item_height": 2,
        "item_weight_unit": null,
    "item_dimensions_unit": null,
    "shipping_profile_id": 172246891939
}'

But if u use a calculated profile the system is not capable to infer the units: when nulls sent the response is:

curl --location --request POST 'https://openapi.etsy.com/v3/application/shops/18976342/listings' \
--header 'Content-Type: application/json' \
--data-raw '{
    "title":"draft",
    "description":"draft",
    "quantity":1,
    "price":1,
    "who_made":"i_did",
    "when_made":"2020_2021",
    "is_supply":"false",
    "taxonomy_id":66,
    "production_partner_ids":[],
    "item_weight": 2,
    "item_length": 2,
    "item_width": 2,
    "item_height": 2,
        "item_weight_unit": null,
    "item_dimensions_unit": null,
    "shipping_profile_id": 175656400825
}'
{
    "error": "This listing uses a calculated shipping profile and must have a weight unit defined."
}

when u omit the response is:

curl --location --request POST 'https://openapi.etsy.com/v3/application/shops/18976342/listings' \
--header 'Content-Type: application/json' \
--data-raw '{
    "title":"draft",
    "description":"draft",
    "quantity":1,
    "price":1,
    "who_made":"i_did",
    "when_made":"2020_2021",
    "is_supply":"false",
    "taxonomy_id":66,
    "production_partner_ids":[],
    "item_weight": 2,
    "item_length": 2,
    "item_width": 2,
    "item_height": 2,
    "shipping_profile_id": 175656400825
}'
{
    "error": "Could not set a calculated shipping profile to the listing.  The listing is missing 'item_weight', 'item_length', 'item_width', 'item_height', 'item_weight_unit' or 'item_dimensions_unit'."
}

I think the profiles should not differ in how they set the default units

yovasx2 avatar Sep 20 '22 23:09 yovasx2

Ah ok so the problem is that we had previously removed the requirement for units on fixed profiles. So, as you noted, in the first response above it shows the two units as null values since they were not included. The endpoint will only save that data which is provided.

For the calculated profile, you will always have to provide the units. We do not ever infer the values on these. There is too much liability in getting it wrong. The Etsy shop manager interface may have a default that shows up in the form, but then it's on the seller to change it if the default is not what they want. We can't say the same for writes via the OpenAPI. Unfortunately, you will have to supply the units if they are not already set on the listing if setting it to a calculated profile.

etsyachristensen avatar Sep 21 '22 20:09 etsyachristensen

gotcha, np

yovasx2 avatar Sep 24 '22 17:09 yovasx2