Support Forum [ All Topics | New Topic ]

Thread: Invalid format error

Hi

I am trying to use,
https://technet.rapaport.com/HTTP/JSON/Prices/GetPriceSheet.aspx

to get price sheet. I am using post request and also passing username,password.

But i am always getting error code 1001, invalid format.

Please help me. I am stuck.


>> add a comment
Anurag
03/10/2013 01:27


16 Replies:

Can you post here the JSON that you send with the request? (strip out your username and password)

Leo


>> add a comment
Leo Muller
3/10/2013 1:34:00 AM
thanks for the quick reply.
Actually i am using a third party API which doesn't give me the actual request. I put parameters in a GUI and it gives me the response.But i have used it extensively and it works fine for other web services.

Basically i am passing username,password in header. And other parameter like shapes, color etc in body.

Can you tell me when you return error code 1001. Its the invalid response content type/data type or request itself has wrong parameters

I can share my screen via team viewer if you have that much time for me. 
Team viewer id : 644 757 677
pwd : 7729


>> add a comment
Anurag
3/10/2013 1:59:00 AM
The error code 1001 means our parser can't read the JSON you provided.
Note that for this service, to get the entire price sheet, you only have to provide a shape, and not color / clarity, etc....

If you want to get the price of a specific diamond, you should use this service:
https://technet.rapaport.com/HTTP/JSON/Prices/GetPrice.aspx

which will accepts shape, size, color and clarity.

Hope this helps, if not, let me know.





>> add a comment
Leo Muller
3/10/2013 3:17:00 AM
No Luck

With the url
 https://technet.rapaport.com/HTTP/JSON/Prices/GetPrice.aspx


and json request:

{
"request": {
"header": {
"username": "********",
"password": "********"

},
"body":{
"shapes": "round",
"color": "E", 
"clarity": "VS2"
}
}
}  

i am getting below response.

{
    
"response":{
        
"header":{
            
"error_code":1001,
            
"error_message":"Invalid format"
        },
        
"body":{
            
        }
    }
}


>> add a comment
Anurag
3/10/2013 3:35:00 AM
Try shape instead of shapes

Leo


>> add a comment
Leo Muller
3/10/2013 3:43:00 AM
Actually i read it is shapes on support forum only.
I tried both anyways.


>> add a comment
Anurag
3/10/2013 3:48:00 AM
If I find the place it says it wrong I will fix that.

In any case, your request should have "shape", and you have to add the "size" as well.

Then it should work.

for example:
https://technet.rapaport.com/HTTP/JSON/Prices/GetPrice.aspx

{
"request": {
"header": {
"username": "XXXXXX",
"password": "XXXXXX"

},
"body":{
"shape": "round",
"size": 2.10,
"color": "E",
 "clarity": "VS2"

} } } 




>> add a comment
Leo Muller
3/10/2013 3:53:00 AM
is there a way to make a curl request?

>> add a comment
Anurag
3/10/2013 9:46:00 AM
I too am getting invalid response.  I am using POSTMan, an API tool.

Here's my raw request:
============
POST /HTTP/JSON/Prices/GetPrice.aspx HTTP/1.1
Host: technet.rapaport.com
Content-Type: application/json; charset=utf-8
Cache-Control: no-cache

{ "request": { "header": { "username": "ericmor", "password": "diamonds" }, "body":{ "shape": "round", "size": 2.10, "color": "E", "clarity": "VS2" } } }
==============

And here is the response:

{
    "response": {
        "header": {
            "error_code": 1001,
            "error_message": "Invalid format"
        },
        "body": {}
    }
}

...with these response headers:
Cache-Control ->private
Content-Encoding ->gzip
Content-Length ->193
Content-Type ->text/html; charset=utf-8
Date ->Sat, 08 Jun 2013 03:14:52 GMT
Server ->Microsoft-IIS/7.0
Vary ->Accept-Encoding
X-AspNet-Version ->4.0.30319
X-Powered-By ->ASP.NET


>> add a comment
Gary
6/7/2013 11:22:00 PM
Hi, 
I used the request you posted here in my sample code and it worked ok so i do not think 
the format is the problem. 
I am now writing to file all the requests for which we return an error message of 'invalid format' 
so if you'll try sending the same request again I can see what is the request 
that actually arrived to our server and maybe we can figure out the problem. 
Please post here the time you sent the request so i can look it up. 
Thanks, 
Yael. 


>> add a comment
Yael
6/9/2013 6:51:00 AM
Hi Yael,

Just POSTed again the same request. It is 10:39AM CDT, June 10th.  

Thank you for your help.
Gary

>> add a comment
Gary
6/10/2013 11:40:00 AM
Hi Gary, 

According to the log file, the request we received from you is an empty string. 
Thats why you got the invalid format message. 
Maybe this link will be of help 
http://technet.rapaport.com/Info/Prices/SampleCode/JSON_CodeSample.aspx
Regards, 
Yael.


>> add a comment
Yael
6/11/2013 3:08:00 AM
Ahh - got it.  

I see from the sample code that the header:

"Content-Type: application/x-www-form-urlencoded"

is sent.  I changed my call to include that instead of "Content-Type: application/json" and it worked.

That's a bit unusual to me as usually if I am sending JSON data we are usually required to send that as the content type.

For other readers, I also sent the json data "raw" 

Thanks for pointing me in the right direction!
Gary

>> add a comment
Gary
6/18/2013 5:13:00 PM
Hello,
Getting same error with nodejs app

Code : 


const fetch = require("node-fetch");

// POST adds a random id to the object sent
fetch('https://technet.rapaport.com/HTTP/JSON/Prices/GetPrice.aspx', {
method: 'POST',
body: {
"shape": "round",
"size": 2.10,
"color": "E",
"clarity": "VS2"
},
headers: {
"Content-Type" : "application/x-www-form-urlencoded",
"username": "XXX",
"password": "XXX"
}
})
.then(response => response.json())
.then(json => console.log(json))


>> add a comment
Raj
5/25/2019 10:09:00 AM

We have tried all possible solutions mentioned on this page to fetch the prices but without any luck. We keep getting the same error "Invalid format" with error code 1001.
We have made many attempts within the past 30 minutes. can you please check and advise what might be causing this error?
Thank you


>> add a comment
Victor
6/15/2019 1:50:00 AM
Please note that we have tried to use the username / password in the headers of the request and in a separate json header block. We also tried using POSTMAN and command line CURL. We also tried sending all parameters (shape, size, etc.) and some set of values. Yet, no matter what we try, it gives the same error. Your hep in this is highly appreciated.

>> add a comment
Victor
6/15/2019 1:52:00 AM