amzn / selling-partner-api-models

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.
Apache License 2.0
547 stars 722 forks source link

putListingsItem body paramter attributes validate #3912

Closed fanhaitao2021a closed 1 month ago

fanhaitao2021a commented 1 month ago

hello, I ask a question,now I invoke putListingsItem publish a goods, a productType has many attributes ,I don't konw which attribute is must submit ,for example productType=LUGGAGE , has 100+ attributes ,now invoke putListingsItem, submit 100+ attributes ?,which is equired

My problem is also to avoid present the code 90220 (attribute_name is required but not supplied.)

fanhaitao2021a commented 1 month ago

frist: I invoke /definitions/2020-09-01/productTypes/LUGGAGE, return image

second: I invoke putListingsItem(/listings/2021-08-01/items/{sellerId}/{sku}), the request body paramter

I don't konw which attribute is must submit ,has 100+ attributes , submit 100+ attributes ?,which is equired I'm struggling with this matter since yesterday.

fanhaitao2021a commented 1 month ago

I also see schema link has "allOf", required attributes refer "allOf"? please tell me ,thanks ,thanks image

chapmanjw commented 1 month ago

@fanhaitao2021a The Definitions API provides standard JSON Schemas to describe which attributes are necessary for a product type and the conditionals which make them applicable. We do not provide support on JSON Schema itself, as that is an open source industry standard.

I would recommend starting here to understand these JSON Schemas along with some example implementations for validating your payloads using these JSON Schemas: https://developer-docs.amazon.com/sp-api/docs/product-type-definition-meta-schema

Additionally, the JSON Schema community has a LOT of documentation and getting started resources for using JSON Schema: https://json-schema.org/

wszwc commented 1 month ago

@chapmanjw Hi, how are you, brother? I have encountered a problem now. When I use feed to submit products in batches, there is no problem. However, when I use put to submit, it always returns 400. However, if my product data triggers the interface verification, it will return normally. Why is this?

chapmanjw commented 1 month ago

@wszwc I suspect there is a contractual piece missing or incorrect on the Listings API PUT submission. Can you share a timestamp + request id for me to investigate? Thanks.

wszwc commented 1 month ago

@chapmanjw I have found the problem. My underlying SDK incorrectly added product data to the route, causing the URL to be too long and a 414 error. Thank you for your help

Yurikohitomi commented 1 month ago

Hi @chapmanjw , "payload of putListingItem validation is being handled elsewhere, so ask them" . Sorry I don't understand English very well, but is that what you mean? but even after following the link you provided, I cannot figure out which attribute in the S3 schema is used for the required check.

Now, even if I tried to create a payload with an attribute that is "required" in the specified schema, I get Lots of errors "Required item missing 90220." In other words, I understand that the key is not field "required”

I just want to know what keywords I should use to search the S3 schema in order to find the requiredattributes for the payload in a putListingItem request. If you know where I can find more clear and understandable information, please let me know.

wszwc commented 1 month ago

@Yurikohitomi Hello, I think he means that jsonschema is an open source structure and has nothing to do with Amazon. I have done relevant development here and can give you some suggestions: 1.The required items you are missing need to be obtained in the allof validation, which requires you to use jsonschema to additionally verify the data to obtain the required items. 2.In addition, if you do not plan to use jsonSchema for validation, it is almost impossible to use it to create a form for users to use. Because as you said, we have no way of knowing what the payload is unless all the attributes are filled in, but this is undoubtedly redundant. 3.However, as a person who has experienced it, I can tell you responsibly that the current validation is relatively difficult to use, and there are many unsatisfactory details. You need to do a lot of extra work to improve it.

wszwc commented 1 month ago

@chapmanjw There are some problems in the validation. I sincerely report some of the problems I know:

  1. The names of the variant themes and the corresponding attributes in jsonschema are different, which sometimes makes it impossible to determine what the corresponding attributes of the variant themes should be? At present, I have solved this problem with similarity matching, but there are still risks.
  2. The tolerance of the backend publication is completely different from that of the API. In many cases, it is allowed in the backend, but not allowed in the API, such as not filling in the brand. Is this intentional?
  3. Currently, jsonschema cannot be used to create form validation well, because all validations are based on existing data. For example, the size enumeration is related to the size system, but I need to select the size system and select the size before returning the corresponding size enumeration, instead of returning the size enumeration after selecting the size system.
  4. I can only get the relationship constraints of the required fields, but not the constraints of the disabled fields. For example, if the battery is required to be true, I can get the required battery item well, but if it is false, it will not tell me that the battery should not be filled in.
Yurikohitomi commented 1 month ago

Hello @wszwc,

Thank you for the advice. It was very helpful. I'll dig into the schema. I'm not really keen on it, though (lol)