Reputation: 173
I am trying to find out how to update data in Dynamics CRM and I fail miserably.
private const string Url = "*****/XRMServices/2011/OrganizationData.svc/";
private const string userName = "username";
private const string password = "password";
private readonly HttpClientHandler _handler;
NetworkCredential credentials = new NetworkCredential(userName, password);
_handler = new HttpClientHandler { Credentials = credentials };
public void Put()
{
StringContent content = new StringContent("<feed><entry><content><m:properties><d:Address1_Country>NEW VALUE</d:Address1_Country></m:properties></content></entry></feed>");
using (HttpClient client = new HttpClient(_handler))
{
client.PutAsync(Url + "AccountSet(guid'182df667-c4f6-e111-8042-0050568e0828')", content).Result;
}
}
The response I get is:
response = {StatusCode: 415, ReasonPhrase: 'Unsupported Media Type', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { DataServiceVersion: 1.0; Persistent-Auth: true Cache-Control: private Date: Tue, 10 Mar 2015 10:22:07 GMT Server: Micr...
Upvotes: 0
Views: 243
Reputation: 5446
You are trying to use OData endpoint that would not work outside of CRM webresources. Try to use SOAP endpoint for your purpose: https://msdn.microsoft.com/en-us/library/gg334754.aspx https://msdn.microsoft.com/en-us/library/gg328416.aspx
Upvotes: 2