Developer Forum [ All Topics | New Topic ]

Thread: Getting 1001 Invalid Format since March, 31

Hi everyone,
We're using Instant Inventory JSON feed for custom app that daily check catalog / reservations.
App makes requests as described here:
http://technet.rapaport.com/Info/RapLink/Format_Json.aspx
http://technet.rapaport.com/Info/RapLink/SampleCode/JSON_CodeSample.aspx
Though format is `applciation/json` we're using `application/x-www-form-urlencoded` as described in the last link. Recently, we started to get "1001 Invalid format" errors. On March, 31, we were unable to sync diamonds.

The request is as follows:
```json
{
"request": {
"header": {
"username": "***",
"password": "***"
},
"body": {
"search_type": "White",
"shapes": ["round","princess","emerald","radiant","cushion","pear","marquise","oval","asscher","heart"],
"fluorescence_intensities": ["none","faint","medium","strong","very strong"],
"size_to": 9.98,
"size_from": 0.18,
"color_from": "D",
"color_to": "M",
"clarity_from": "IF",
"clarity_to": "I1",
"cut_from": "Excellent",
"cut_to": "Fair",
"polish_from": "Excellent",
"polish_to": "Fair",
"symmetry_from": "Excellent",
"symmetry_to": "Fair",
"table_percent_from": "0",
"table_percent_to": "100",
"depth_percent_from": "0",
"depth_percent_to": "100",
"labs": ["GIA"],
"price_total_from": 400,
"price_total_to": 5000000,
"page_number": 0,
"page_size": 50,
"sort_by": "Price",
"sort_direction": "ASC"
}
}
}
```

This was working for several years, but now there's an error with no details.

Could you please specify what changed in API and how should we make the request?

Thank you.


>> add a comment
Dmitry Burlakov
04/05/2022 06:23


13 Replies:

I also see that all individual diamonds I've checked with Single Diamond Endpoint have 3001 error
https://technet.rapaport.com/HTTP/JSON/RetailFeed/GetSingleDiamond.aspx

[NullReferenceException: Object reference not set to an instance of an object.]


>> add a comment
Dmitry Burlakov
4/5/2022 6:31:00 PM
Even without all optional params request returns 1001 Invalid format
```json
{
"request": {
"header": {
"username": "***",
"password": "***"
},
"body": {
"page_number": 1,
"page_size": 50
}
}
}
```
Response:
```json
{
"response": {
"header": {
"error_code": 1001,
"error_message": "Invalid format"
},
"body": {}
}
}
```


>> add a comment
Dmitry Burlakov
4/5/2022 6:41:00 PM
Hi Dmitry
Please can we have your RapNet account number 
Your code looks ok 
I need to check your account details 

Thanks 


>> add a comment
RapNet Technical
4/6/2022 2:42:00 AM
Hi Dmitri
I ran your code on our side 

{
"request": {
"header": {
"username": "*****",
"password": "******"
},
"body": {
"search_type": "White",
"shapes": ["round","princess","emerald","radiant","cushion","pear","marquise","oval","asscher","heart"],
"fluorescence_intensities": ["none","faint","medium","strong","very strong"],
"size_from": 0.18,
"size_to": 10,
"color_from": "D",
"color_to": "M",
"clarity_from": "IF",
"clarity_to": "I1",
"cut_from": "Excellent",
"cut_to": "Fair",
"polish_from": "Excellent",
"polish_to": "Fair",
"symmetry_from": "Excellent",
"symmetry_to": "Fair",
"price_total_from": 100,
"price_total_to": 150000,
"labs": ["GIA","IGI"],
"table_percent_from": "0",
"table_percent_to": "100",
"labs": ["GIA"],
"page_number": 1,
"page_size": 20,
"sort_by": "price",
"sort_direction": "Asc"
}
}
}

------------------------------------------------------------------------------------------------------------

The output I received
{
"response": {
"header": {
"error_code": 0,
"error_message": ""
},
"body": {
"search_results": {
"diamonds_returned": 20,
"total_diamonds_found": 28060,
"sorted_by" :"PRICE",
"sort_direction": "ASC"
},


Please compare your code 
Thanks 


>> add a comment
RapNet Technical
4/6/2022 3:00:00 AM
Hi,
Our RapNet ID is 19849.
Tried to run request again -- still the same error. Also tried to run request with parameters similar to the message below -- same error too. Hmm.
Let me know if there's something with our account, I can talk with management if some additional actions/subscriptions needed for our account.
Thank you for quick response!


>> add a comment
Dmitry Burlakov
4/6/2022 5:43:00 AM
Please check your end points 
The endpoints should be 

https://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx 

and  not 

http://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx
Thanks 
No


>> add a comment
RapNet Technical
4/6/2022 5:56:00 AM
Hi, just checked, we use secure (https) endpoints.
Fetches made with GuzzleHttp library, which works around cURL.
In short, code looks like this:
$client = new GuzzleHttp\Client();

$diamondsResponse = $client->post(
'https://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx',
array(
'headers' => array(
'Content-Type' => 'application/x-www-form-urlencoded'
),
'body' => $rawRequest
)
);
Where $rawRequest is raw JSON body.
I also making requests from Postman 2 app, but having the same responses.
Best regards


>> add a comment
Вьшекн
4/6/2022 7:25:00 AM
Hi 
Please can you give me your e-mail address 
I would like to send you the correct code 
Using Postman 

Thanks 

>> add a comment
RapNet Technical
4/7/2022 5:33:00 AM
Please use this email: dantaeusb [at] live [dot] com.
This will help a lot, I'll review it and fix the code if there are any mistakes. Though, I want to emphasize that everything worked well until April.
Thank you very much.


>> add a comment
Dmitry Burlakov
4/7/2022 8:45:00 AM
Hi!
Thank you for sending Postman request info. I believe I adjusted couple of fixes and used wrong code for testing (tried to reach page 0, where page starts at 1).
Right now by checking logs on our production server I see that request were stopped with message "User is sending too many requests". I believe it's some kind of request limiter here. Could you specify or email me with information about request limiting, so we can adjust our software to have a timeout before next request?
Best Regards


>> add a comment
Dmitry Burlakov
4/8/2022 8:59:00 AM
Also, could you please specify which error code is returned with "User is sending too many requests".
Unfortunately I can't really always reproduce the error as the request limiting seems to be quite soft, so in order to handle such errors and make a delay before retry I would like to match error code to retry diamonds fetching.
Best Regards


>> add a comment
Dmitry Burlakov
4/8/2022 10:09:00 AM
Hi 
There is a known issue regarding " too many requests " 
We are investigating this 
I will update you as soon as we have answers 

Thanks 

>> add a comment
RapNet Technical
4/10/2022 3:41:00 AM
The issue with "too many requests " has been resolved 
Thanks 

>> add a comment
RapNet Technical
4/11/2022 2:25:00 AM