Hi,
I'm facing issue while updating ownerid field of an entity with team,using odata json call,
my code is as follows:
publicasyncTask TestUpdateUsingJson()
{
var complaintcasedata = newnew_complaintcase();
complaintcasedata = GetComplaintCaseStub();
var recordid = complaintcasedata.new_complaintcaseid;
JObject jsondata = newJObject();
jsondata["ownerid@odata.bind"] = "/teams(" + complaintcasedata.ownerid + ")";
var ComplaintCaseResult = await serviceRequestProcessor.Update(jsondata,recordid, "new_complaintcases");
}
in above code new_complaintcase is my custom entity,in which I'm trying to update ownerid with teams
GetComplaintCaseStub() method in above method has dummy data as follows:
privatestaticnew_complaintcase GetComplaintCaseStub()
{
var complaintCase = newnew_complaintcase();
complaintCase.new_aduserguid = "8604b472-edff-48d2-b0e6-dc83f7e241a6";
complaintCase.new_businessareaid = "Customer Relations";
complaintCase.new_casestatus = 100000000;
complaintCase.new_complaintagainst = 100000000;
complaintCase.new_complaintcaseid = Guid.Parse("3E482AFB-2190-4D4D-8383-6E0D13697E3C");
complaintCase.new_complaintdate = DateTime.Now;
complaintCase.new_complaintraisedbytypes = "Customer";
complaintCase.new_customernames = "Mrs N Qiehsaw, Mr M Ogcfqyu";
complaintCase.new_departmentraisedby = "IT";
complaintCase.new_originalcomplaintdate = DateTime.Now;
complaintCase.new_outstandingtask = "";
complaintCase.new_primaryaccount = "10003225";
complaintCase.new_primaryelementwithsubcategoryandcategory = "Redemption, Fees incorrectly applied";
complaintCase.new_primaryloanaccount = newnew_loan { new_loanid = Guid.Parse("96771835-9162-434B-B3D1-0B88B33DB379"), new_name = "10003225" };
complaintCase.new_requestmethod = 100000001;
complaintCase.new_rootcause = 99999999;
complaintCase.new_sendcorrespondence = true;
complaintCase.new_summary = "test";
complaintCase.new_teamownerreason = "test";
complaintCase.new_type = 100000000;
complaintCase.new_username = "ABC";
complaintCase.ownerid = newteam { name = "Customer Relations", teamid =Guid.Parse("37f8b9a4-e7b9-e511-80fb-3863bb353f28"),businessunitid=Guid.Parse("c9635b80-e4b9-e511-80f9-3863bb34e990") };
return complaintCase;
}
and below is my odata update call
publicasyncTask<string> Update(JObject entityTobeUpdated, Guid recordid, string clientURL)
{
var recordId = recordid.ToString();
try
{
//Create HttpClient object to send and receive Http Requests and Response
var httpClient = await _connectionManager.CreateHttpClient();
using (httpClient)
{
var jsonData = JsonConvert.SerializeObject(entityTobeUpdated);
HttpRequestMessage request = newHttpRequestMessage(newHttpMethod("PATCH"), newUri(httpClient.BaseAddress + clientURL)) { Content = newStringContent(jsonData, System.Text.Encoding.UTF8, "application/json") };
var response = await httpClient.SendAsync(request);
//If the response is Successfully executed then it will return the value true
if (response.IsSuccessStatusCode)
{
var recordUrl = response.Headers.GetValues("OData-EntityId").FirstOrDefault();
var splitRetrievedData = recordUrl.Split('[', '(', ')', ']');
recordId = splitRetrievedData[1];
}
}
}
catch (Exception exception)
{
thrownewCustomODataException(exception.Message, exception);
}
return recordId;
}
I'm getting error that "method is not allowed",so I'm unable to update my owner id with team...please help me where I'm going wrong!