|  | 
 
	
    
    
    
        
            |  $.ajax({     url: 'https://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx',     type: 'POST',     data: {          "request": {       "header": {       "username": "myusername",        "password": "mypass"       },        "body": {           "search_type": "White",            "shapes": ["Round", "Pear", "Princess", "Marquise", "Oval", "Radiant", "Emerald", "Heart", "Cushion", "Asscher"],            "size_from": 0.01,            "size_to": 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",           "page_number": 1,            "page_size": 20,             "price_total_from": 100,            "price_total_to": 100000,            "labs": ["GIA","IGI","AGS", "HRD", "NONE", "CGL"],            "sort_by": "price",            "sort_direction": "Asc"            }        }          },     headers: {          'Content-Type' : 'application/x-www-form-urlencoded'     },     contentType : 'application/x-www-form-urlencoded',     success: function (data) {         console.log(data);     } }); 
 I'm getting this error:
 { "response": { "header": { "error_code": 1001, "error_message": "Invalid format" }, "body": { } } }
 What am I doing wrong in my code? Please help!
 
 
 |  
            | >> add a comment | 
                    Foxtrot05/28/2016 05:25
 |  
            |  |  
		
        
             
                1
                Replies:
                    
                        |  |  
                        | Hi Foxtrot, you need to add JSON.stringify() to your request data, see my code -
 
 
  $.ajax({                 url: 'https://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx',                 type: 'POST',                 data:  JSON.stringify({                     "request": {                         "header": {                             "username": "myusername",                             "password": "mypass"                         },                         "body": {                             "search_type": "White",                             "shapes": ["Round", "Pear", "Princess", "Marquise", "Oval", "Radiant", "Emerald", "Heart", "Cushion", "Asscher"],                             "size_from": 0.01,                             "size_to": 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",                             "page_number": 1,                             "page_size": 20,                             "price_total_from": 100,                             "price_total_to": 100000,                             "labs": ["GIA", "IGI", "AGS", "HRD", "NONE", "CGL"],                             "sort_by": "price",                             "sort_direction": "Asc"                         }                     }                 }),                 contentType: "text/plain",                 headers: {                     'Content-Type': 'application/x-www-form-urlencoded'                 },                 contentType: 'application/x-www-form-urlencoded',                 success: function (data) {                     console.log(data);                 },                 error: function (data) {                     console.log(data);                 }             }); 
 let me now if you have more questions,
 Inbal
 
 
 |  
                        | >> add a comment | 
                                Inbal5/29/2016 4:57:00 AM
 |  |