I am trying to update customer data. I have been able to update a customer record using swagger, but I am not able to update using either Postman or Visual Studio.
In Postman, I have this URL
https://…/api/v1/Erp.BO.CustomerSvc/Customers(ARM,2004)
{
"Customer_SyncToCRM_c": true,
"Customer_CRMAccountID_c": "A6UJ9A0030GI"
}
response:
{
"odata.error": {
"code": "",
"message": {
"lang": "en-US",
"value": "The request is invalid."
},
"innererror": {
"message": "patch : An error has occurred.\r\n",
"type": "",
"stacktrace": ""
}
}
}
In Visual Studio, I tried this
var client = new RestClient("https://../api/v1/Erp.BO.CustomerSvc/Customers(ARM,2004)");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Postman-Token", "f1b8c..");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Authorization", "Basic dHB..");
var iJsonData = new
{
Company = "ARM",
CustNum = 2004,
CRMAccountID_c = "A6UJ9A002SSQ"
};
request.AddObject(iJsonData, "Company", "CustNum", "CRMAccountID_c");
IRestResponse response = client.Execute(request);
JSONResponse = response.Content;
StatusBox.Text = JSONResponse;
The response:
{
"odata.error":{
"code":"","message":{
"lang":"en-US","value":"The request is invalid."
},"innererror":{
"message":"patch : An error has occurred.\r\n","type":"","stacktrace":""
}
}
}