Connect Web Services for SOAP: Create a Contact

After retrieving the WSDL and be aware of the API Operations you are ready to get, create, update and delete RightNow records through Web Services.

In this post an example will be presented on how to create a Contact. On the documentation available (Connect Web Services for SOAP) we can see the sample code and then adapt to our case.

To create a Contact we shall use the “Create” API Operation. The request message shall have:

  • An Envelope;
  • A Header;
  • A Body;

Envelope

<soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:v1=“urn:messages.ws.rightnow.com/v1_2” xmlns:v11=“urn:base.ws.rightnow.com/v1_2”>
[Include here the Header and the Body]
</soapenv:Envelope>

Header

Notice the AppID tag with the Operation name “Basic Create”

<soapenv:Header>
  <ns7:ClientInfoHeader xmlns:ns7=“urn:messages.ws.rightnow.com/v1_2” soapenv:mustUnderstand=“0”>
     <ns7:AppID>Basic Create</ns7:AppID>
  </ns7:ClientInfoHeader>
  <wsse:Security xmlns:wsse=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd&#8221; mustUnderstand=“1”>
     <wsse:UsernameToken>
        <wsse:Username>Username</wsse:Username>
        <wsse:Password Type=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText&#8221;>Password</wsse:Password>
     </wsse:UsernameToken>
  </wsse:Security>
</soapenv:Header>

Body

Notice the Create tag and the RNObjects tag with the xsi:type = “Contact”

<soapenv:Body>
<ns7:Create xmlns:ns7=“urn:messages.ws.rightnow.com/v1_2”>
——<ns7:RNObjects xmlns:ns4=“urn:objects.ws.rightnow.com/v1_2” xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:type=“ns4:Contact”>
———<ns4:Emails>
————<ns4:EmailList action=“add”>
—————<ns4:Address>example.email@rightnow.com</ns4:Address>
—————<ns4:AddressType>
——————<ID xmlns=“urn:base.ws.rightnow.com/v1_2” id=“0” />
—————</ns4:AddressType>
————</ns4:EmailList>
———</ns4:Emails>
———<ns4:Name>
————<ns4:First>FirstName</ns4:First>
————<ns4:Last>LastName</ns4:Last>
———</ns4:Name>
——</ns7:RNObjects>
</ns7:Create>
</soapenv:Body>

4 thoughts on “Connect Web Services for SOAP: Create a Contact

  1. Hi Luis,
    I am trying a similar thing with Incident, but I am getting a fault in response. Below is the code as a request:

    Basic Create

    testuser
    testuser

    Banner SOAP UI

    This incident is created via SOAP UI

    This incident thread is created via SOAP UI

    false
    false

    Below is the response:

    soapenv:Sender
    Data element in the Message is NULL

    RightNowSyncService|urn:wsdl.ws.rightnow.com/v1_2 failed
    Found 0 elements < (minOccurs = 1) for element RNObjects of object CreateMsg
    Failure in setting value for object Create element Create of type messages_ws_rightnow_com_v1_2::CreateMsg
    NULL returned from the Create deserializer due to missing or invalid XML

    I am clueless about this fault.
    Endpoint URL is:
    https://xyz.rightnowdemo.com/cgi-bin/xyz.cfg/services/soap

    Any suggestions?

    Thanks,
    Shreyas

  2. Hi Luis,
    I am trying a similar thing with Incident, but I am getting a fault in response. Below is the code as a request:

    Basic Create

    testuser
    testuser

    Banner SOAP UI

    This incident is created via SOAP UI

    This incident thread is created via SOAP UI

    false
    false

    Below is the response:

    soapenv:Sender
    Data element in the Message is NULL

    RightNowSyncService|urn:wsdl.ws.rightnow.com/v1_2 failed
    Found 0 elements < (minOccurs = 1) for element RNObjects of object CreateMsg
    Failure in setting value for object Create element Create of type messages_ws_rightnow_com_v1_2::CreateMsg
    NULL returned from the Create deserializer due to missing or invalid XML

    I am clueless about this fault.
    Endpoint URL is:
    https://xyz.rightnowdemo.com/cgi-bin/xyz.cfg/services/soap

    Any suggestions?

    Thanks,
    Shreyas

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s