Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    kate James
    Unable to create a contact object
    Topic posted November 16, 2019 by kate JamesRed Ribbon: 250+ Points, tagged SOAP 
    46 Views, 4 Comments
    Title:
    Unable to create a contact object
    Summary:
    .NET API to create contact and incidents
    Content:

    Hi all,

    I'm trying to follow the tutorial for connect Web Services for SOAP with .NET. However, for some reasons, my web application is throwing an error in Create

    Severity Code Description Project File Line Suppression State
    Error CS7036 There is no argument given that corresponds to the required formal parameter 'ProcessingOptions' of 'RightNowSyncPortClient.Create(ClientInfoHeader, APIAccessRequestHeader, RNObject[], CreateProcessingOptions, out RNObject[])'
     
    Tutorial link: http://documentation.custhelp.com/euf/assets/devdocs/cloud19c/Connect_Web_Services_for_SOAP/Default.htm
     
     
     
    Does anyone knows why I am getting this error?
     
    Thank you in advance!

    Kate

    Version:
    2018B
    Code Snippet:

    Comment

     

    • Tushar Gupta

      Please share the complete code.

      • kate James

        Hi Tushar,

        Thank you for looking into. Please note that I am using VS 2019 and ASP.NET Web - C#.

        I added the web service reference using the URL: https://<your_site>/services/soap/connect/soap?wsdl=typed 

         

        using System;
        using SampleApplication.ServiceCloudReference;
         
        namespace SampleApplication
        {
            class SampleClient
            {
                private RightNowSyncPortClient _service;
             
                public SampleClient()
                {
                    _service = new RightNowSyncPortClient();
                     
                    _service.ClientCredentials.UserName.UserName = "xx";
                    _service.ClientCredentials.UserName.Password = "xx";
                }
                 
                public long CreateContact()
                {
                    Contact newContact = populateContactInfo();
                    APIAccessRequestHeader aPIAccessRequestHeader = new APIAccessRequestHeader();
                     
                 
                    ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
                    clientInfoHeader.AppID = "This ID";
                     
                    CreateProcessingOptions createProcessingOptions = new CreateProcessingOptions();
                    createProcessingOptions.SuppressExternalEvents = false;
                    createProcessingOptions.SuppressRules = false;
                    RNObject[] createObjects = new RNObject[] { newContact };
                    
                    RNObject[] createResults = _service.Create(createObjects, createProcessingOptions, clientInfoHeader, aPIAccessRequestHeader);
                     
                    newContact = createResults[0] as Contact;
                    return newContact.ID.id;
                }
                 
                private Contact populateContactInfo()
                {
                    Contact newContact = new Contact();
                    PersonName personName = new PersonName();
                    personName.First = "Martin";
                    personName.Last = "Smith";
                    newContact.Name = personName;
                    Email[] emailArray = new Email[1];
                    emailArray[0] = new Email();
                    emailArray[0].action = ActionEnum.add;
                    emailArray[0].actionSpecified = true;
                    emailArray[0].Address = "myemail@dd.com";
                    NamedID addressType = new NamedID();
                    ID addressTypeID = new ID();
                    addressTypeID.id = 1;
                    addressType.ID = addressTypeID;
                    addressType.ID.idSpecified = true;
                    emailArray[0].AddressType = addressType;
                    emailArray[0].Invalid = false;
                    emailArray[0].InvalidSpecified = true;
                    newContact.Emails = emailArray;
                    return newContact;
                }
                 
           protected void btnsearch_Click(object sender, EventArgs e)
                {
                    SampleClient sampleClient = new SampleClient();
                     
                    try
                    {
                        long newContactID = sampleClient.CreateContact();
                        
                    }
                    catch (Exception ex)
                    {
                       
                    }
                     
                   
                }
            }
        }       

         

        Thank you.

        Kathy

        • Tushar Gupta

          Hi Kate,

          I have made small changes. It's working. Let me know in case of any issues. 

           

          using System;
          using CreateContact.ServiceCloudReference;

          namespace CreateContact
          {
              class SampleClient
              {
                  private RightNowSyncPortClient _service;
                  static void Main(string[] args)
                  {
                     SampleClient sampleClient = new SampleClient();
                  }

                  public SampleClient()
                  {
                      _service = new RightNowSyncPortClient();

                      _service.ClientCredentials.UserName.UserName = "XX";
                      _service.ClientCredentials.UserName.Password = "XX";

                      CreateContact();
                  }

                  public long CreateContact()
                  {
                      Contact newContact = populateContactInfo();


                      ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
                      clientInfoHeader.AppID = "This ID";

                      CreateProcessingOptions createProcessingOptions = new CreateProcessingOptions();
                      createProcessingOptions.SuppressExternalEvents = false;
                      createProcessingOptions.SuppressRules = false;

                      RNObject[] createObjects = new RNObject[] { newContact };

                      RNObject[] createResults = _service.Create(clientInfoHeader,createObjects, createProcessingOptions);

                      newContact = createResults[0] as Contact;
                      return newContact.ID.id;
                  }

                  private Contact populateContactInfo()
                  {
                      Contact newContact = new Contact();
                      PersonName personName = new PersonName();
                      personName.First = "Martin";
                      personName.Last = "Smith";
                      newContact.Name = personName;
                      Email[] emailArray = new Email[1];
                      emailArray[0] = new Email();
                      emailArray[0].action = ActionEnum.add;
                      emailArray[0].actionSpecified = true;
                      emailArray[0].Address = "myemail@dd.com";
                      NamedID addressType = new NamedID();
                      ID addressTypeID = new ID();
                      addressTypeID.id = 1;
                      addressType.ID = addressTypeID;
                      addressType.ID.idSpecified = true;
                      emailArray[0].AddressType = addressType;
                      emailArray[0].Invalid = false;
                      emailArray[0].InvalidSpecified = true;
                      newContact.Emails = emailArray;
                      return newContact;
                  }

                  protected void btnsearch_Click(object sender, EventArgs e)
                  {
                      SampleClient sampleClient = new SampleClient();

                      try
                      {
                          long newContactID = sampleClient.CreateContact();

                      }
                      catch (Exception ex)
                      {

                      }


                  }
              }
          }