web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

OData by C#

(0) ShareShare
ReportReport
Posted on by

Hello to everyones...

In your opinion there is the possibility to consume OData service using an HttpRequest (and Response) by C#? That I'd like to do is a some lines of code to retrieve a contact's guid...

Any idea?

Thanks!!!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aileen Gusni Profile Picture
    44,524 on at

    Hi Marco,

    I think it is possible.

    I found a sample before from Microsoft, you can try to download its sample in Social Care Application Sample:

    http://www.microsoft.com/en-us/download/confirmation.aspx?id=43122

    or

    http://go.microsoft.com/fwlink/?LinkId=396802

    And here is the article:

    https://msdn.microsoft.com/en-us/library/dn744885(v=crm.6).aspx

    Open the file, install it, will install code files with folders and there is an example inside the CRMConnect.cs file

    crmconnect2.png

     

    And you can find example while in the code the objective is to retrieve Contact, Case, Social Profile, Queue, Convert Case Rule, etc.

     

    So, based on the snippet here:

    // Build and send the HTTP request. 

    // Build and send the HTTP request.  
    string url = _serviceUrl + "ContactSet" + "?$select=FirstName,LastName,FullName,EMailAddress1,Telephone1,Address1_Country,ParentCustomerId,ContactId";
    
    if (searchStr.Length > 0)
    {
       url = url + "&$filter=substringof('" + searchStr + "',FullName)";
    }

     

    That is to retrieve contact by Name, retrieving contact columns including Contact id (guid) as well.
    I can conclude that this is possible, you can see we can do Query like we did usually in OData query in javascript CRM form.

    But it is little bit confused if using CRM Online because you need ODataAPI and ODataAuth

    Authentication and the OData API

    This sample uses the CRM OData endpoint. Since the sample application is a separate application (and not a web resource within CRM), it needs to authenticate explicitly against the OData endpoint. The sample app can use regular domain credentials to talk to the on-premises CRM server. For working against Microsoft Dynamics CRM Online and Internet-facing deployments (IFDs) of CRM, the sample app uses OAuth for authentication. 

    I think the challenge here is to make the authentication, last time I posted in my blog the tutorial to run this apps, but most of people have trouble in the authentication and cannot make connect to CRM, while last time I tried, it was not too difficult, but there was a little bit chance in the ODataAuth which you need to authenticate against Azure as well, this one I am not sure, if you found it worked you can share it out and let me know, how to authenticate it better.

    If you are OnPremise User without IFD, this is very easy in term of authentication, I think you can learn from that framework, if CRM Online, actually I never try it again since the new authentication applied. If you found it worked, let me know, how to do that, okay.

    But answering your question, yes there is, because I saw the example there.

    Hope this helps you.

    Thank you.

  • Suggested answer
    Sayhaitokumar Profile Picture
    7,042 on at

    Hi Marco,

    yes, there is possibility for the OData Services. To retrieve contact's GUID please follow the steps given in the below link

    msdn.microsoft.com/.../bb929001.aspx

    stackoverflow.com/.../how-to-get-the-contact-guids-from-a-partylist-in-a-plugin

    There are many easy ways to get GUID of record. I don't know why you prefer this way. I didn't tried this method, but there is possibility

  • Community Member Profile Picture
    on at

    Marco,

    Could you please share the use case you are addressing to solve?

    thank you,

    harihar

  • ACECORP Profile Picture
    1,589 on at

    I have a similar question that deals with additional specifics and would greatly appreciate and have several specific pieces of information or input I am seeking. If anyone wishes to address it, my question can be found here - https://community.dynamics.com/crm/f/117/t/180101 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans