Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Price Importer > add check for invalid json #39

Open
emtii opened this issue Sep 3, 2015 · 3 comments
Open

Price Importer > add check for invalid json #39

emtii opened this issue Sep 3, 2015 · 3 comments

Comments

@emtii
Copy link

emtii commented Sep 3, 2015

In my first step I created a json what looked like this

{
    "prices": [
        {
            "sku": "4001513102164",
            "prices": {
                    "value": {
                        "centAmount": 199,
                        "currencyCode": "EUR"
                    },
                "country": "DE"
                }
        }
}

When I just have one price per SKU this is a valid json. Well when I used the importer he logged a lot of wraps to say "nothing to update". After fixing my json to a "valid" json for your endpoint the import finally worked. so my "valid" json looked like this:

{
     "prices": [
        {
            "sku": "4001513102164",
            "prices": [
                {
                    "value": {
                        "centAmount": 199,
                         "currencyCode": "EUR"
                    },
                     "country": "DE"
                }
            ]
        }
 ]
}

I really would love to get some kind of validation error when my json is "not valid" for your import endpoint instead of just getting nothing.

@emmenko
Copy link
Member

emmenko commented Sep 3, 2015

The validation part is still missing yes, but we have a json schema for that.
https://github.com/sphereio/sphere-json-schemas/blob/master/schema/price.schema.json

Have you also looked at the documentation?
https://github.com/sphereio/sphere-product-import/wiki/Price-Importer#sample-input

Also as a side note, prices usually implies more then one, so an array right? ;)

@emtii
Copy link
Author

emtii commented Sep 3, 2015

You're absolutely right, but sometimes a customer wishes imports in around 5 minutes hacked so when you think its easy, its not because of too less time to think. I looked into the schema+docs, yes, and I also started my own documentation (https://github.com/emtii/commercetools-json-examples) because its easier/faster for me to read & understand just as best practices ...

@emmenko
Copy link
Member

emmenko commented Sep 3, 2015

Cool!

Anyway, this is still WIP, so any feedback is very welcomed. We will try to improve the documentation on our side as well.

PS: be aware that the schema for the different imports doesn't necessary correspond 1:1 to the actual schema of the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants