title: Java integration with CRM Dynamics 2011 problems
body: <p>First time poster here!</p>
  
  <p>I am trying to consume the MS CRM dynamics web services via Java. I followed this tutorial <a href="http://code.msdn.microsoft.com/Consuming-CRM-REST-Service-ae24a15e" rel="nofollow">here</a> and managed to get that working. Currently I am trying to just add, edit, select and remove accounts from CRM via the web services. I have managed to add accounts and query accounts using the following code below.</p>
  
  <p>Add Account:</p>
  
  <pre><code>MicrosoftCrmSdkDataServicesService service = new MicrosoftCrmSdkDataServicesService(); Account act = new Account(); 
  act.setName("test account");
  try 
  { 
      service.addEntity(act);
  }  
  catch (Exception e)  
  { 
      e.printStackTrace(); 
  }
  </code></pre>
  
  <p>Query Account (returns account name):</p>
  
  <pre><code>MicrosoftCrmSdkDataServicesService service = new MicrosoftCrmSdkDataServicesService(); 
  try 
  { 
      Query&lt;Account&gt; act1 = service.createAccountQuery("/AccountSet");
      Iterator&lt;Account&gt; accountTest = act1.iterator();
      while ( ((Iterator&lt;Account&gt;) accountTest).hasNext() )
      {
           String h = accountTest.next().getName().toString();
           if (h.equalsIgnoreCase("test account"))
           {
                System.out.print(hello);
           }
       }
  }  
  catch (Exception e)  
  { 
      e.printStackTrace(); 
  }
  </code></pre>
  
  <p>So the problem comes when i'm trying to update and delete an entity from CRM using the service.UpdateEntity(obj) and service.DeleteEntity(Obj) methods. However when doing these and passing in an account object I got this error:</p>
  
  <pre><code>Bad Request (400) - Can't update this entity http://domain:port/organization/xrmservices/2011/organizationdata.svc/AccountSet(9c1d0adc-08ed-e111-aece-00155d046501)
      at org.restlet.ext.odata.Service.updateEntity(Service.java:1243)
      at client.main(client.java:87)
  </code></pre>
  
  <p>From this it shows that I am putting in the correct object into the updateEntity as it is auto generating the correct guid into the Query URL. However it is doing it in the wrong format. It should be (as this loads of the RSS feed for AccountSet and that specific account):</p>
  
  <pre><code>http://domain:port/organization/xrmservices/2011/organizationdata.svc/AccountSet(guid'9c1d0adc-08ed-e111-aece-00155d046501')
  </code></pre>
  
  <p>Could the web services method i'm using be out of date and not of any use any more?
  Is there something blatant I am doing wrong that I am not picking up on?</p>
  
  <p>Thanks,
  Sam</p>