0 Replies Latest reply: Apr 22, 2013 5:19 PM by 1003430 RSS

    How to Query Contact in C#

    1003430
      I am attempting to query a contact. Below are the steps and hopefully i am doing something wrong.

      1) Download Contact Custom WSDL for Web Services v2.0
      2) Add the WSDL as a service reference to the Visual Studio project
      3) Login using the Establish() from sample code
      4) See code below - CRMOD.ContactClient does not have a URL like the examples I have seen with account, so I cannot not set the sessionID using the url().
      - when this is called I get a "Server" exception.

      private void TestContactButton_Click(object sender, RoutedEventArgs e)
      {
      try
      {
      Session s = new Session();
      s.username = "username here";
      s.password = "password here";

      s.Establish();

      CRMOD.ContactClient client = new CRMOD.ContactClient();

      CRMOD.ContactQueryPage_Input input = new CRMOD.ContactQueryPage_Input();

      input.ListOfContact = new CRMOD.ListOfContactQuery();

      CRMOD.queryType queryType = new CRMOD.queryType();
      queryType.Value = "000655898";
      input.ListOfContact.Contact = new CRMOD.ContactQuery();
      input.ListOfContact.Contact.AccountId = queryType;

      client.ContactQueryPage(input);

      CRMOD.ContactQueryPage_Input test = input;

      }
      catch (Exception ex)
      {
      int test = 1;
      }
      }

      Also, I am confused in why my instance of web services does not have an account WSDL.

      Thanks.