Developer Forum [ All Topics | New Topic ]

Thread: How to implement instant inventory for mobile application using react native

How to implement instant inventory for mobile application using react native

>> add a comment
Vinod
02/26/2020 06:18


3 Replies:

Hi 
The Instant inventory widgets work on a fetch API 
Here is some information regarding how to use
fetch in React
https://reactjs.org/docs/faq-ajax.html

I have also included links to help you integrate your Instant inventory code 
https://technet.rapaport.com/Info/RapLink/Widgets.aspx

Here is the API codes :
curl --location --request POST 'https://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-raw '
{
"request": {
"header": {
"username": "",
"password": ""
},
"body": {
"search_type": "White",
"shapes": ["round","Princess","pear"],
"size_from": 0.2,
"size_to": 15.3,
"color_from": "D",
"color_to": "K",
"clarity_from": "IF",
"clarity_to": "VS2",
"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": "26.0",
"table_percent_to": "66.0",
"page_number": 1,
"page_size": 20,
"sort_by": "price",
"sort_direction": "Asc"
}
}
}'




>> add a comment
Neil
2/26/2020 8:33:00 AM
Thread: Getting error_code 1001

ERROR:

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


my Code 

fetch('https://technet.rapaport.com/HTTP/JSON/Prices/GetPriceSheet.aspx',
{
"request": {
"header": {
"username": "xxxxxx",
"password": "xxxxx"
},
"body":{
"shape": "round"
}
}
})
.then(response => response.json())
.then(response => {
console.log('myresponse',response)
.catch(error => {
this.setState({ error: 'Something just went wrong'});
});


>> add a comment
Vinod
3/2/2020 6:49:00 AM
Hi 
I tested your code and I received the following error 
{
"response": {
"header": {
"error_code": 1001,
"error_message": "Invalid format"
},
"body": {
}
}
}


So from the code I see you are missing certain entries 

I have attached code that has been tried and tested :
curl --location --request POST 'https://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-raw '{
"request": {
"header": {
"username": " ",
"password": " "
},
"body": {
"search_type": "White",
"shapes": [
"Round"
],
"size_from": "1",
"size_to": "10",
"page_number": "1",
"page_size": "20"
}
}
}'

and 
{
"request": {
"header": {
"username": " ",
"password": " "
},
"body": {
"search_type": "White",
"shapes": [
"Round"
],
"size_from": "1",
"size_to": "10",
"page_number": "1",
"page_size": "20"
}
}
}





>> add a comment
Anon
3/3/2020 4:25:00 AM