You need to sign in to do that
Don't have an account?

place order / bad request
I am trying to programmatically create an order using REST API (.net c#)
I have tried:
1. Add an Order to an existing A/C : /services/data/v30.0/commerce/sale/order
2. Add Order Products to an Existing Order: /services/data/v30.0/commerce/sale/order/[Order Ref]
In both attempts I get a Bad Request (400).
If I take Option 1 above as an example.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
string uri5 = "https://[salesforce app url/services/data/v30.0/commerce/sale/order";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(uri5);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Headers.Add("Authorization", "OAuth " + token);
httpWebRequest.Headers.Add("Authorization", "Bearer " + token);
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string jsonnew = "";
//build the json as described in
https://developer.salesforce.com/docs/atlas.en-us.api_placeorder.meta/api_placeorder/sforce_placeorder_rest_api_place_order_account.htm
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
using (var myResponse = httpWebRequest.GetResponse() as HttpWebResponse)
{
if (httpWebRequest.HaveResponse && myResponse != null)
{
using (var streamReader = new StreamReader(myResponse.GetResponseStream()))
{
....do stuff here
}
}
}
I have tried:
1. Add an Order to an existing A/C : /services/data/v30.0/commerce/sale/order
2. Add Order Products to an Existing Order: /services/data/v30.0/commerce/sale/order/[Order Ref]
In both attempts I get a Bad Request (400).
If I take Option 1 above as an example.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
string uri5 = "https://[salesforce app url/services/data/v30.0/commerce/sale/order";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(uri5);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Headers.Add("Authorization", "OAuth " + token);
httpWebRequest.Headers.Add("Authorization", "Bearer " + token);
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string jsonnew = "";
//build the json as described in
https://developer.salesforce.com/docs/atlas.en-us.api_placeorder.meta/api_placeorder/sforce_placeorder_rest_api_place_order_account.htm
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
using (var myResponse = httpWebRequest.GetResponse() as HttpWebResponse)
{
if (httpWebRequest.HaveResponse && myResponse != null)
{
using (var streamReader = new StreamReader(myResponse.GetResponseStream()))
{
....do stuff here
}
}
}