Consuming OData Service From An External .NET Application RRS feed

  • Question

  • Hi All,

    I want to know whether OData service can be consumed against a MSCRM 2015 IFD deployment from a .NET application which is scheduled to run on a third party server? I mean to say that the service URL is the one which ends with OrganizationData.svc and the .NET application [console application] is run from a server where MSCRM is not installed.

    If it works, can you please share a code snippet of how authentication is made to perform CRUD operations against CRM data for IFD deployment?

    Monday, June 8, 2015 5:40 AM

All replies

  • As far as I know, this is not supported - the organizationdata.svc is only designed for access from client code running within the Crm client. Even if it were possible, there is no documentation on how to manage the authentication.

    If you're accessing Crm from .Net, the first choice would be to use the Crm .Net assemblies. If that's not possible (e.g. due to .Net versions), then the next choice is to use web service calls to organization.svc

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Monday, June 8, 2015 8:30 AM
  • You can find out the URL for the Organization by going into CRM and go to Settings->Customization->Developer Resources, there you can see the service end points.

    If you wan´t early bound objects with your CRM system you could use CRMSVCUtil.exe to extract the metadata from CRM into a .cs file you can include in your project.

    If you wan´t to use late bound objects with your CRM system you only need to include the CRM 2015 SDK DLLs.

    In the SDK you could check out the following sample that shows authentication examples and CRUD commands. \SDK\SampleCode\CS\QuickStart\

    Hope this helps you in some way.

    Halldór Jóhannsson

    Monday, June 8, 2015 9:34 AM
  • An update on this:

    I tried using the OrganizationData.svc service [http://MyURL/MyOrgName/XRMServices/2011/OrganizationData.svc, here it is HTTP] for non-IFD CRM organization, and I was able to query data from CRM using REST [LINQ] successfully. Same path I take to add a service for an IFD CRM, I get following error when trying to add OrganizationData.svc URL service reference [https://MyURL/MyOrgName/XRMServices/2011/OrganizationData.svc, here it is HTTPS]:

    The HTML document does not contain Web service discovery information.
    Metadata contains a reference that cannot be resolved: 'https://MyURL/MyOrgName/XRMServices/2011/OrganizationData.svc'.
    The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
    <head><meta http-equiv="X-UA-Compatible" content="IE=8" /><title>
    Sign In
    </title><link rel="stylesheet" type="text/css" href="MasterPages/StyleSheet.css" /><meta name="robots" content="noindex, nofollow" /></head>

        <form name="aspnetForm" method="post" action="/adfs/ls/?wa=wsignin1.0&amp;wtrealm=https%3a%2f%2fMyURL%2f&amp;wctx=rm%3d1%26id%3dbe0c03e5-c148-460d-b312-214ce8fcc954%26ru%3d%252fMyOrgName%252fXRMServices%252f2011%252fOrganizationData.svc&amp;wct=2015-06-09T06%3a31%3a53Z&amp;wauth=urn%3afederation%3aauthentication%3awindows" id="aspnetForm">
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUIMTM0NzQwMDFkZB8vA1tnEjn0lp5e9kcE+bomTXz1" />

    <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="1736B89C" />
    <input type="hidden" name="__EV'.
    If the service is defined in the current solution, try building the solution and adding the service reference again.

    Any help on this? Thanks in advance.

    Tuesday, June 9, 2015 6:46 AM
  • Looks like the response you get is a prompt for credentials, which is what I'd expect. As per my previous post, use Organization.svc instead

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Tuesday, June 9, 2015 8:57 AM
  • Have you tried putting Metadata contains a reference that cannot be resolved: 'https://MyURL/MyOrgName/XRMServices/2011/OrganizationData.svc'. into your browser and see if it opens up from there?

    Halldór Jóhannsson

    Tuesday, June 9, 2015 8:57 AM
  • Thanks for your valuable inputs DavidJ.

    Whenever I access the OrganizationData.svc URL from browser, I get redirected to a SSO page where I am supposed to choose a dropdown value for SSO. Upon chooosing an option and clicking on OK, I get a prompt for credentials. My query is, if there is a way to add an "OrganizationData.svc" service reference for a non-IFD CRM, how can it be achieved for an IFD deployment?

    As you've mentioned in the earlier post, I understand there is no documentation for this from Microsoft. Please keep me posted if you have any fruitful information for me.

    Tuesday, June 9, 2015 5:54 PM
  • Thanks for your message HBJ. I am able to browse "https://MyURL/MyOrgName/XRMServices/2011/OrganizationData.svc" without any issue from my IE.
    Tuesday, June 9, 2015 5:55 PM