Crawling error with serverless function

i am trying to get my store running with a serverless function. but i always get the same crawling error
Reason: ‘product-crawling-failed’

— Item 1 —
[Item ID] AP002
[Item Unique ID] b355dd53-45bd-4a65-8baa-3dadce61b7be
[Item Name] A Un Passant
[Url] https://frabjous-bienenstitch-01b1bd.netlify.app/.netlify/functions/product?id=AP002
[Status] NotFound
[Price in cart] 25
[Crawled prices] []

[Details] We have not been able to find item with id ‘AP002’ at ‘https://frabjous-bienenstitch-01b1bd.netlify.app/.netlify/functions/product?id=AP002’. Please make sure the product is correctly defined. We suggest you take a look at this section of our documentation:
{kind: ‘cart-confirmation’, reason: ‘product-crawling-failed’, technicalReason: {…}, data: Array(1), code: ‘snipcart.errors.order_validation.product_crawling’, …}

the function seems to print all the information correctly, i can not copy it in here, since i am only allowed two links…

really lost here, i have been loosing a day on this already…

any help would be most appreciated… thank you in advance, best patrick

Hey Patrick,

I think it’s due to your response header. It needs to be content type application/json, it’s currently text in your link : Order validation – Snipcart Documentation

it is not a cors issue. but seems to be a invalid product problem. in snipcart i get the following log

DATE MESSAGE
JUN 13 08:37:41 An attempt to create an order with invalid products has been made. Don’t forget you can’t add/update items attributes in the cart dynamically with javascript as it will cause crawling issues. You can read more about this here:
JUN 13 08:37:41 Using JSON crawler http://docs.snipcart.com/configuration/json-crawler) to validate item ‘AP002’ located at https://frabjous-bienenstitch-01b1bd.netlify.app/.netlify/functions/product?id=AP002’.

it first tries to validate here?
Validating item with id ‘AP002’ located at frabjous-bienenstitch-01b1bd.netlify.app/.netlify/functions/product?id=AP002’ on domain ‘amusementparking.com’.

i dont understand how this could be flaged as spam?

The bot had an issue with you sending multiple posts with the same links in them. I restored them.

I will take a look at the rest of your messages later.

I’ve checked your website and json for the crawler. It seems like the JSON is missing the customFields attribute. Since you have one on your website, it requires it, but your custom attribute doesn’t change the price, so you don’t need to add the specific field to the JSON. An empty "customFields": [] will do the job.

thank you very much. i added them but still get a cors error in console and in the snipcart log i am told that the product is invalid?

i have just one json file, that contains all the information. this populates my html and the serverless function. so i am really confused, that this does not work.

also, if i try to fetch the products in the json file through the dashboard, it only takes two of them, ignores the currency eur but gives them the euro price (by now i changed my json file to just one currency to rule this out as the source of the problem).

and sorry again for the flagged post. all a bit new for me.

The customFields in the JSON Crawler needs to be in an array. Like so :

"customFields": [
    {
      "name": "author",
      "value":"Dominic Haydn Rawle"
      "type":"readonly"
    },
  ]

But as mentionned, you do not need to actually put them in. You can just have "customFields":[] The crawler only checks for custom values which modify the prices. There is a small bug with the crawler that requires the field to exist instead of assuming there are no price changes when not existing.

I also noticed you currently have multi currency in the page, but not the crawler.

Another note, I am actually not quite sure on the impact, but try removing the " around the number fields in your JSON, if you still have some issues. So dimensions and prices. But the example in the docs for multi-currency has " around the values, so not sure it has an impact of the doc is wrong. I’ll have to confirm and update it if it is so.

"dimensions":{"weight":250,"height":4,"length":15,"width":18}
"price":{"usd": 25, "eur": 20, "chf": 20}

it works… thank you so much. you made my day.

on a side note, i realised that i can not go with multicurrencies because of the standard shipping rates. as you can only put in one amount there, this could go awfully wrong, depending on the currencies.

would not be a tragedy in my case, with chf eur and usd. but for some this could be a disaster. just thought i let you know…

Thanks, I’ll note it somewhere. See if we can do something about it, either change the docs or implement some quick multi-currency in shipping. But the custom shipping is supposed to be quite simple. For larger implementations with rules and multi-currencies, we suggest using either integrated shipping providers or custom webhooks.