question

richa avatar image
richa asked ·

Getting blank in response on hitting add product API

I am trying to insert products in clover using create inventory item api.When I am create multiple products using for loop in my script sometimes in get response blank instead of getting product details of created product.For example : I am trying to create 50 products through for loop. So for each product created api returns me data as follows :

(

[data] => Array

(

[id] => 06CKBXEKDEDQ6

[hidden] =>

[name] => ROMANA BLACK SAMBUCA 750ML

[code] => 08676722106

[sku] => 9000479

[price] => 3299

[priceType] => FIXED

[defaultTaxRates] => 1

[cost] => 2307

[isRevenue] => 1

[modifiedTime] => 1620754724000

);

)

But sometimes it returns me blank as:

(

[data] =>

)

If I check for that product where it returns me empty data ,it is created in clover but I get response empty.Can you say me reason for such case?

Inventory
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
David Marginian avatar image
David Marginian answered ·

Are you checking the response status for each request you make and verifying it was successful (200)? Calling our API blindly in a loop is going to quickly lead to being rate-limited (429 response) - https://docs.clover.com/docs/api-usage-rate-limits and I am guessing that is what is happening here.

7 comments
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

But if thats the case it should return 429 response instead of blank right? Also API call are one after another means if it will give success than only script will move ahead.

0 Likes 0 ·

The response body and response status code are two separate things. Since you haven't shared the request you are making and the response you are receiving I can't tell you what is happening. Any time you make a call to the REST API you needto make sure you are getting a successful response code (200).

0 Likes 0 ·
richa avatar image richa David Marginian ♦♦ ·

But I am not getting anything in response body or response status.I am getting blank only as I have shared above. My Request data be :

$clover_sync_data = array(

'name' => product_name,

'price' => unit_price * 100,

'priceType' => 'FIXED',

'sku' => sku,

'code' => barcode,

'cost' => unit_cost *100

);

This request data works correctly for all products.It sends me response :

(

[data] => Array

(

[id] => XXXXX

[hidden] =>

[name] => RON ABUELO 7 YEAR ANEJO 750ML

[code] => 08829101232

[sku] => 154011

[price] => 2599

[priceType] => FIXED

[defaultTaxRates] => 1

[cost] => 2119

[isRevenue] => 1

[modifiedTime] => 1620755992000

)

)


But after some products are added , it gives me response:

(

[data] =>

)

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community