d
Topic
Posts:
7
October 26, 2014

Error 400 when try to create orders containing billing_address and/or shipping_address with API This post is outdated

Hi

We have a big problem when we try to create an order with Orders API that contains the id of an existing customer and billing_address and/or shipping_address data.
This is the JSON posted from our .Net app (asp.net):

{"order": 
{  
"send_webhooks": true,  
"email": "romeomauit@gmail.com",  
"financial_status": "pending",  
"taxes_included": true,  
"line_items": 
[   
{      
"fulfillment_service": "manual",      
"price": 4.80,      
"quantity": 1,      
"variant_id": 886491731,      
"tax_lines": 
[
{          
"price": 0.93,          
"rate": 0.24,          
"title": "VAT"        
}      
]    
}  
],  
"tax_lines": 
[    
{      
"price": 1.03,      
"rate": 0.24,      
"title": "VAT"    
}  
],  
"shipping_lines": 
[    
{      
"code": "Livrare",      
"title": "Livrare",      
"source": "shopify",      
"price": 0.5000,      
"tax_lines": 
[        
{          
"price": 0.10,          
"rate": 0.24,          
"title": "VAT"        
}      
]    
}  
],  
"billing_address": 
[    
{      
"address1": 
"Strada din Bucuresti nr 1, sector 2",      
"city": "Bucuresti",      
"first_name": "Laurentiu",      
"last_name": "Mauit",      
"phone": "02112345678",      
"zip": "Bucuresti",      
"country": "Romania",      
"country_code": "RO"    
}  
],  
"shipping_address": 
[    
{      
"address1": "Strada din Bucuresti nr 1, sector 2",      
"city": "Bucuresti",      
"first_name": "Laurentiu",      
"last_name": "Mauit",      
"phone": "02112345678",      
"zip": "Bucuresti",      
"country": "Romania",      
"country_code": "RO"    
}  
],  
"customer": 
{    
"id": 239785967  
}
}
}

The returned error is 400 (Bad request)

The customer already has account in our shop: id = 239785967.

We have noticed that the issue comes from billing_address and shipping_address: when one of these two exists in JSON we get error.

Otherwise it works fine.

If we send the same JSON but without billing_address and shipping_address the order is created in Shopify just fine.

We've tried also to use the "id" (299819087) for billing_adress (since the customer already exists in Shopify), without the other address fields, but with same result (error 400).
We've tried also different other combinations for the JSON but without any luck.

What we are doing wrong?
 

Thanks in advance

Laurentiu

i
Replies
Posts:
7
October 26, 2014

found the error: billing_address and shipping_address are not Arrays, but Objects. 

After correction it works jus fine