- DarkLight
Troubleshooting Orders that aren't created when using API calls
- DarkLight
When creating orders via an API call to Yotpo, you may see a 200-OK confirmation, but the order isn't created on Yotpo's backend when checking it via a GET call.
Reason 1: Wrong endpoint is used
Make sure you are pointing to the relevant resource for your request. For example, if you're calling the single create API, use https://api.yotpo.com/apps/:app_key/purchases/For the mass create API, use https://api.yotpo.com/apps/:app_key/purchases/mass_create.json
Reason 2: validate_data value is in quotes
The validate_data is a Boolean property, so make sure you don't put it in single or double quotes as a string. Such requests will return 200-OK, but the order won't get created. The correct format is this:
"validate_data" : true,
Reason 3: Wrong Encoding
Some automated integration tools can set the request to a certain encoding. Make sure the request body is encoded as UTF-8. There have been cases where an otherwise valid request was sent in the wrong encoding and responded with 200-OK , but orders were not created.
Reason 4: HTTP header missing
Orders requests must include the following HTTP header for with every call: "content-type: application/json". One way to test this is to create a http://requestb.in and have them post their order to that URL. You can then check to ensure that the JSON and the HTTP header are correct.
Reason 5: Information not in quotes
All the variables in the JSON must be inside quotes (except for validate_data ) - you can see in the screenshot below that the "order_id" and "name" variables don't have quotes before and after the data.
Reason 6: Delays on Yotpo's backend
Since all orders created are entering a queue on Yotpo's end, we would recommend waiting a couple of hours before checking if the order has been received.
Sample Single Order Create:
POST https://api.yotpo.com/apps/DsVSLp1V2hR7I61HkTFYFdASd/purchases
{
"validate_data": true,
"platform": "general",
"utoken": "5KS69gfxtymYGa8RYF27WT1tbnASAze8rkhLVglZ",
"email": "client@abc.com",
"customer_name": "bob",
"order_id": "order_1",
"order_date": "2010-10-14",
"currency_iso": "USD",
"products": {
"SKUaaa12": {
"url": "http://example_product_url1.com",
"name": "product1",
"image": "http://images2.fanpop.com/image/photos/13300000/A1.jpg",
"description": "this is the description of a product",
"price": "100",
"specs": {
"upc": "USB",
"isbn": "thingy"
},
"product_tags": "books"
}
}
}
Sample Mass Order Create:
POST http://api.yotpo.com/apps/DsVSLp1V2hR7I61HkTFYFdASd/purchases/mass_create
{
"validate_data": true,
"platform": "general",
"utoken": "NqJwYoQYNcUY5odr6cA6xhXoZPqpnDzRFO1y7MXl",
"orders": [
{
"email": "bill@abc.com",
"customer_name": "bill",
"order_id": "aaa",
"order_date": "2015-12-28",
"currency_iso": "USD",
"products": {
"SKU13241": {
"url": "http://www.gkshops.com/USBthingy.html",
"name": "USBthingy",
"image": "http://images2.fanpop.com/image/photos/13300000/A1.jpg",
"description": "This is the description of a product",
"price": "39",
"specs": {
"upc": "USB",
"isbn": "thingy"
}
},
"bbb12": {
"url": " http://www.gkshops.com/BigUSBthingy.html ",
"name": " BigUSBthingy ",
"image": "http://images2.fanpop.com/image/photos/13300000/A2.jpg",
"description": "This is just what you always wanted. ",
"price": "29",
"specs": {
"upc": "USB",
"isbn": "Big"
}
}
}
},
{
"email": "bob@abc.com",
"customer_name": "bob",
"order_id": "bbb",
"order_date": "2015-12-29",
"currency_iso": "USD",
"products": {
"SKUaaa22": {
"url": "http://example_product_url1.com",
"name": "product1",
"image": "http://images2.fanpop.com/image/photos/13300000/A2.jpg",
"description": "this is the description of a product",
"price": "69",
"specs": {
"upc": "Mega-product"
}
}
}
}
]
}