Developer Forum [ All Topics | New Topic ]

Thread: Not able to use the JSON Inventory link properly

I am trying to use the json api for raplink website http://technet.rapaport.com/Info/RapLink/Format_Json.aspx and I am facing a lot of issues:

1) Sometimes I get the results and rest of the times I get a blank screen

2) I am not able to retrieve any shape other than round. Even if I remove cut property and choose pear as shape, I still get round diamonds only

3) When I change any property sometimes I get results or I don't.

4) If I remove symmetry from and to sometimes I get the results.

5) Chane page number or page size, I get no results

Please help as this is very important for me to work. What could I be doing wrong? I am posting my json post here:


{
"request": {
"header": {
"username": "73953",
"password": "mypassword"

},
"body": {
"shape": ["Pear"],
"size_to": 50.0,
"size_from":0.1,
"color_from": "D",
"color_to": "M",
"clarity_from": "IF",
"clarity_to": "SI1",
"polish_from": "Excellent",
"polish_to": "Fair",
"labs": ["GIA", "IGI", "AGS", "HRD", "EGL_USA", "NONE"],
"price_total_from": 1,
"price_total_to": 100000,
"page_number": 1,
"page_size": 50,
"sort_by": "price",
"sort_direction": "ASC"
}
}
}


>> add a comment
Gaurav Chandra
02/20/2013 10:02


27 Replies:

Hi,

We had a mistake in our documentation. The name of the shape parameters should be "shapes", so like this:
"shapes": ["Pear"]

For the other issues you brought up, can you give me the specific JSON request that you send, so we can check?

Thanks

Leo





>> add a comment
Leo Muller
2/21/2013 4:49:00 AM
Hey, Thanks Leo. The shapes part took care of the problem. This is the json I am sending:

{
"request": {
"header": {
"username": "73953",
"password": "mypasswordhere"
},
"body": {"shapes": ["Pear"],"size_to": 50.0,"size_from":0.1,"color_from": "D","color_to": "M","clarity_from": "IF","clarity_to": "SI3","polish_from": "Excellent","polish_to": "Fair","symmetry_from": "Excellent","symmetry_to": "Fair","labs": ["GIA", "IGI", "AGS", "HRD", "EGL_USA", "NONE"],"price_total_from": 1,"price_total_to": 1000000,"page_number":1,"page_size": 15,"sort_by": "price","sort_direction": "ASC"}}}

Can you please also glance over and check whether there is a problem on UPPER CASE or lowercase or not or is it taken care of at the web services end automatically? Thanks again.

>> add a comment
Gaurav Chandra
2/21/2013 5:34:00 AM
The case of the values doesn't matter, we accept all.



>> add a comment
Leo
2/21/2013 7:56:00 AM
Thanks, Leo. But I don't get the reply from the server or I get a blank reply as soon as I change the page number. Here is the request:
{"request": {"header": {"username": "73953","password": "mypasswordhere"},"body": {"shapes": ["Round", "Pear", "Princess", "Marquise", "Oval", "Radiant", "Emerald", "Heart", "Cushion", "Asscher"],"size_to": 50,"size_from":0.1,"color_from": "D","color_to": "M","clarity_from": "IF","clarity_to": "SI3","cut_from": "Excellent","cut_to": "Fair","polish_from": "Excellent","polish_to": "Fair","symmetry_from": "Excellent","symmetry_to": "Fair","labs": ["GIA", "IGI", "AGS", "HRD", "EGL_USA", "NONE"],"price_total_from": 1,"price_total_to": 100000000,"page_number": 2,"page_size": 15,"sort_by": "price","sort_direction": "ASC"}}}

Don't know how to solve this problem. I am stumped.


>> add a comment
Gaurav Chandra
2/26/2013 9:00:00 AM
hi Gaurav,
You can send the request only by Post request and not as a query string.
You can see an example of post request in this link-


>> add a comment
Inbal
2/27/2013 8:37:00 AM
Hi Inbal,

Thanks for the reply. I am using php and curl with post request only. The problem I face is :

1) I send a request via curl post to fetch diamonds with first page
2) Now I need diamonds on second page so I send the same request with, as post via curl, "page_number" : 2
3) I get a blank page in return and curl output shows me 200 OK reply. I don't even get an INVALID REQUEST of error code from the server.

I am accessing the json api from my website url against which the account was created.

This is a problem which I am facing. As soon as I request the first page again, I get the diamonds. This happens quite often. I am not able to get 51st diamond as the max diamonds per page returned  are 50 from Rapnet web service. 

>> add a comment
Gaurav Chandra
3/4/2013 3:29:00 AM
hi Gaurav,
i tried to use the request you posted here with this changes- 
"page_number" : 2, "page_size": 50 and i got diamonds. are u using this code too ?
you can send me your request to my email- inbal.avraham@diamonds.net


>> add a comment
inbal
3/5/2013 6:02:00 AM
  Hi Inbal,

Thanks for the reply. Sorry, I am late in responding. Everything started working fine but now things are again choppy.

The problem I am facing is now with values which contain space like "cut_from": "Very Good". As soon as I use Very Good, I get an [error_code] => 1001 [error_message] => Invalid format but when I use either excellent or fair or good, I get results. 

This is happening in cut, symmetry and polish only. Can you check and let me know as it stopped working suddenly.

Here is my complete request
{
            "request": {
                "header": {
                    "username": "73953",
                    "password": "mypassword"
                },
                "body": {
                    "shapes": ["Round", "Pear", "Princess", "Marquise", "Oval", "Radiant", "Emerald", "Heart", "Cushion", "Asscher"],
                    "size_to": 50,
                    "size_from":0.1,
                    "color_from": "F",
                    "color_to": "M",
                    "clarity_from": "VVS1",
                    "clarity_to": "SI3",
                    "cut_from": "Very Good",
                    "cut_to": "Fair",
                    "polish_from": "Excellent",
                    "polish_to": "Fair",
                    "symmetry_from": "Excellent",
                    "symmetry_to": "Fair",
                    "labs": ["GIA", "IGI", "AGS", "HRD", "EGL_USA", "NONE"],
                    "price_total_from": 1,
                    "price_total_to": 100000000,
                    "page_number": 1,
                    "page_size": 15,
                    "sort_by": "price",
                    "sort_direction": "ASC"
                }
            }
        }


>> add a comment
Gaurav Chandra
3/15/2013 7:49:00 AM
It started working automatically one fine day. So, I am not facing any problem now. It is working fine. 

>> add a comment
Gaurav Chandra
3/29/2013 7:08:00 AM
We actually fixed the problem on our side last week... I wasn't aware of this thread.

Leo


>> add a comment
Leo Muller
4/2/2013 1:28:00 AM
I experienced issues with the JSON service... it seems sometimes the service provides invalid JSON as the response.

If any diamond in a JSON result set has an empty value for a numeric field, rapnet responds with a blank value instead of zero or double quotes.  Here's an example of invalid JSON that comes back from rapnet:

{
"diamond_id":44595905
"shape":"Emerald"
"size":0.050
"color":"G"
"clarity":"VS1"
"cut":"Very Good"
"symmetry":"Very Good"
"polish":"Very Good"
"depth_percent":
"table_percent":
"meas_length":4.80
"meas_width":3.20
"meas_Depth":2.70
"girdle_min":""
"girdle_max":""
"girdle_condition":""
"culet_size":""
"culet_condition":""
"fluor_color":""
"fluor_Intensity":"None"
"has_cert_file":"False"
"lab":"NONE"
"total_sales_price":80.0000
"cert_num":""
"stock_num":"OB21154"
}

Notice that for "depth_percent" there is no value.  In order to be valid JSON, the value should be a zero or empty double-quotes.  The solution is to replace these instances before calling json_decode() (for those using PHP).

This worked for me (I'm also using cURL).

$valid_json = preg_replace('/":,/', '":"0",', curl_exec($handle));


>> add a comment
Aaron Cicali
4/16/2013 9:19:00 AM
You are correct, we fixed this now.
depth_percent and table_percent will now give null when there is no value.

>> add a comment
Leo
4/18/2013 12:07:00 AM
Hello Sir,
                 I am trying to get data from this link "http://technet.rapaport.com/HTTP/RapLink/download.aspx" with passing parameter shape,color,clarity,size and price for match search criteria that entered by user but i get zero record from it, so plz help me about this and reply as soon as possible. Thank You!

>> add a comment
Sandip
1/1/2014 1:20:00 AM
Is this service included in your subscription? You need DLS for this. Second of all, if you can paste the EXACT url that you use, including parameters, that will be helpful.

>> add a comment
Leo Muller
1/1/2014 1:26:00 AM
Hello Sir,
                  Thanks for replying me,Here is my URL with parameter : "http://technet.rapaport.com/HTTP/RapLink/download.aspx?ShapeIDs=Round&CaratSizeFrom=0.10&CaratSizeTo=1&pricefrom=100&priceto=10000&colorfrom=D&colorto=F&cutfrom=EX-EX-EX&cutto=GD-GD-GD&clarityfrom=IF&clarityto=VS1"


>> add a comment
Sandip
1/1/2014 1:47:00 AM
Looks like a problem with your parameters. (cut) try to create the URL through this form: http://www.rapnet.com/Rapnet/DownloadListings/Download.aspx

>> add a comment
Leo Muller
1/1/2014 1:49:00 AM
Hello Sir,
                  I try to get data using this URL "http://www.rapnet.com/Rapnet/DownloadListings/Download.aspx?ShapeIDs=Round&CaratSizeFrom=0.10&CaratSizeTo=1&pricefrom=100&priceto=10000&colorfrom=D&colorto=F&cutfrom=EX-EX-EX&cutto=GD-GD-GD&clarityfrom=IF&clarityto=VS1" but is also display zero record. now what should i do?


>> add a comment
Sandip
1/1/2014 1:54:00 AM
You misunderstood, go in your browser to http://www.rapnet.com/Rapnet/DownloadListings/Download.aspx In that page, choose the parameters you want. then click "generate code", and that will give you the correct URL for downloading in the text box under the button. Leo

>> add a comment
Leo Muller
1/1/2014 2:05:00 AM
Hello Sir,
                  Ok sir. but when i open this url "http://www.rapnet.com/Rapnet/DownloadListings/Download.aspx" from browser it display following error that : " The page could not be found (404), the page you requested was: unknown page.". Now what should i do?

>> add a comment
Sandip
1/1/2014 2:11:00 AM
That is very odd... try to go first to www.rapnet.com, then after logging in, go in the top menu to : more > Download Listings Service (4th from the bottom) if that doesn't help, contact customer service.

>> add a comment
Leo
1/1/2014 2:19:00 AM
Ok sir. Is it possible to get data from this url "http://technet.rapaport.com/HTTP/RapLink/download.aspx"
with passing parameter?

>> add a comment
Sandip
1/1/2014 2:23:00 AM
Kindof, if you go the page above, you will see it will create a URL with parameters, starting with the link you provided. The parameters are part of the URL.

>> add a comment
Leo Muller
1/1/2014 8:52:00 AM
I want to get all diamond details but  i am getting blank screen. 

 here is my code

{
"request": {
"header": {
"username": "99259",
"password": "here is my password"
},
"body": {
"shapes": ["Round", "Pear", "Princess", "Marquise", "Oval", "Radiant", "Emerald", "Heart", "Cushion", "Asscher"],
"size_to": 2.0,
"size_from": 0.0,
"color_from": "D",
"color_to": "M",
"clarity_from": "IF",
"clarity_to": "I1",
"cut_from": "Excellent",
"cut_to": "Good",
"polish_from": "Excellent",
"polish_to": "Good",
"symmetry_from": "Excellent",
"symmetry_to": "Good",
"labs": ["GIA","IGI", "AGS","HRD","NONE","CGL"],
"price_total_from": 0.00,
"price_total_to": 20000.00,
"page_number": 1,
"page_size": 15,
"sort_by": "price",
"sort_direction": "ASC"
}
}
}

I am sending this details using php and curl and url which i am using to fetch details is  
https://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx

Kindly suggest me where i am doing mistakes...




>> add a comment
Punit
2/4/2016 3:24:00 AM
I got results with your account with code below :

$data = '{"request": {"header": {"username": "yourusername","password": "your password"},
"body": {
"shapes": ["Round", "Pear", "Princess", "Marquise", "Oval", "Radiant", "Emerald", "Heart", "Cushion", "Asscher"],
"size_to": 2.0,
"size_from": 0.0,
"color_from": "D",
"color_to": "M",
"clarity_from": "IF",
"clarity_to": "I1",
"cut_from": "Excellent",
"cut_to": "Good",
"polish_from": "Excellent",
"polish_to": "Good",
"symmetry_from": "Excellent",
"symmetry_to": "Good",
"labs": ["GIA","IGI", "AGS","HRD","NONE","CGL"],
"price_total_from": 0.00,
"price_total_to": 20000.00,
"page_number": 1,
"page_size": 15,
"sort_by": "price",
"sort_direction": "ASC"
}}}';
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

curl_setopt($curl, CURLOPT_URL, 'http://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
echo('Results: ');
$result = curl_exec($curl);
echo($result);
curl_close($curl);


>> add a comment
Reuven
2/4/2016 3:50:00 AM
Hii Renuven, Thank you for your reply, but when i added your above code in my live server with my login username and password , i got nothing . It's just simply giving me o/p as

"Results:"
 
kindly tell me what changes i need to do or need to check any thing in my code to get all diamond details. 



>> add a comment
Punit
2/5/2016 1:20:00 AM
Hii Reuven,  

Now when i am using this code locally  it's working fine but at server it's giving me blank page.

why is it, any idea?










>> add a comment
Punit
2/5/2016 1:35:00 AM
probably it is blocked in your server, maybe try check the firewall.

>> add a comment
Reuven
2/8/2016 5:25:00 AM