Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Sebastiaan Draaisma
    Soap XML create exampleAnswered
    Topic posted October 20, 2018 by Sebastiaan DraaismaBlack Diamond: 60,000+ Points, last edited October 20, 2018, tagged SOAP 
    70 Views, 2 Comments
    Title:
    Soap XML create example
    Summary:
    Create incident for new and exsisting contact
    Content:

    I'm following the XML sample code but I have a hard time understanding the result I get.

    A first attempt gave me Invalid ID: No such Contact with ID = 1 making me believe I need to know the contact id from the contact I'm going to create an incident for (not sure how this would work for new contacts)

    A second attempt I used my exsisting contact id and exsisting details which gave me

    <faultstring>Cannot save/create: Contact: An email address was used that already exists
    While performing create on Contact</faultstring>

    This confused me. I then changed the name and email address while keeping the contact id (just to experiment). The code run without any errors but the result is that a new contact is created with a new contact id and that the incident created in this code is assigned to the contact id used in the code.

    My questions are:

    1. How does one create a new incident for a new contact
    2. How does one create a new incident for an exsisting contact

    EDIT: I think I understand the behavior. From what I understand with my limmited knowledge of API :-) is that this code simply contains 2 non related requests (as I see 2 RNObjects sections)
    1 request to create a new contact & 1 request to create an incident for a specified contact id (correct me if I'm wrong)

    Version:
    Aug 17
    Document:
    Document:

    Best Comment

    Vlad

    I think you are right, the requests are not related. When you create an incident, you can reference the primary contact either by ID or by Lookup Name. The lookup name is first name + a space + last name. If you use lookup name and there are 0 or more than 1 contacts with that lookup name, an error would be returned. In the example below, the contact created in the RNObjects above the incident is used in the incident itself. But still, the requests are separate.

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <soapenv:Header>
          <ns7:ClientInfoHeader soapenv:mustUnderstand="0" xmlns:ns7="urn:messages.ws.rightnow.com/v1_4">
             <ns7:AppID>Basic Create</ns7:AppID>
          </ns7:ClientInfoHeader>
          <wsse:Security mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
             <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">password</wsse:Password>
             </wsse:UsernameToken>
          </wsse:Security>
       </soapenv:Header>
       <soapenv:Body>
          <ns7:Create xmlns:ns7="urn:messages.ws.rightnow.com/v1_4">
        <ns7:RNObjects xmlns:ns4="urn:objects.ws.rightnow.com/v1_4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns4:Contact">
                    <ns4:Emails>
                        <ns4:EmailList action="add">
                            <ns4:Address>jane.smith132@example.com</ns4:Address>
                            <ns4:AddressType>
                                <ID xmlns="urn:base.ws.rightnow.com/v1_4" id="0" />
                            </ns4:AddressType>
                        </ns4:EmailList>
                    </ns4:Emails>
                    <ns4:Name>
                        <ns4:First>Jane123</ns4:First>
                        <ns4:Last>Smith132</ns4:Last>
                    </ns4:Name>
                </ns7:RNObjects>
             <ns7:RNObjects xsi:type="ns4:Incident" xmlns:ns4="urn:objects.ws.rightnow.com/v1_4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <ns4:PrimaryContact>
                        <ns4:Contact>
                            <Name xmlns="urn:base.ws.rightnow.com/v1_4" type="rnb_v1_4:NamedID">Jane123 Smith132</Name>
                        </ns4:Contact>
                </ns4:PrimaryContact>
                <ns4:Subject>This is a newly created incident.</ns4:Subject>
             </ns7:RNObjects>
             <ns7:ProcessingOptions>
                <ns7:SuppressExternalEvents>false</ns7:SuppressExternalEvents>
                <ns7:SuppressRules>false</ns7:SuppressRules>
             </ns7:ProcessingOptions>
          </ns7:Create>
       </soapenv:Body>
    </soapenv:Envelope>
    But there may be a way to somehow create the associated contact directly as Incident.PrimaryContact. I wasn't able to do it. This would also apply to ConnectPHP I think.

    Comment

     

    • Vlad

      I think you are right, the requests are not related. When you create an incident, you can reference the primary contact either by ID or by Lookup Name. The lookup name is first name + a space + last name. If you use lookup name and there are 0 or more than 1 contacts with that lookup name, an error would be returned. In the example below, the contact created in the RNObjects above the incident is used in the incident itself. But still, the requests are separate.

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
         <soapenv:Header>
            <ns7:ClientInfoHeader soapenv:mustUnderstand="0" xmlns:ns7="urn:messages.ws.rightnow.com/v1_4">
               <ns7:AppID>Basic Create</ns7:AppID>
            </ns7:ClientInfoHeader>
            <wsse:Security mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
               <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">password</wsse:Password>
               </wsse:UsernameToken>
            </wsse:Security>
         </soapenv:Header>
         <soapenv:Body>
            <ns7:Create xmlns:ns7="urn:messages.ws.rightnow.com/v1_4">
          <ns7:RNObjects xmlns:ns4="urn:objects.ws.rightnow.com/v1_4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns4:Contact">
                      <ns4:Emails>
                          <ns4:EmailList action="add">
                              <ns4:Address>jane.smith132@example.com</ns4:Address>
                              <ns4:AddressType>
                                  <ID xmlns="urn:base.ws.rightnow.com/v1_4" id="0" />
                              </ns4:AddressType>
                          </ns4:EmailList>
                      </ns4:Emails>
                      <ns4:Name>
                          <ns4:First>Jane123</ns4:First>
                          <ns4:Last>Smith132</ns4:Last>
                      </ns4:Name>
                  </ns7:RNObjects>
               <ns7:RNObjects xsi:type="ns4:Incident" xmlns:ns4="urn:objects.ws.rightnow.com/v1_4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                  <ns4:PrimaryContact>
                          <ns4:Contact>
                              <Name xmlns="urn:base.ws.rightnow.com/v1_4" type="rnb_v1_4:NamedID">Jane123 Smith132</Name>
                          </ns4:Contact>
                  </ns4:PrimaryContact>
                  <ns4:Subject>This is a newly created incident.</ns4:Subject>
               </ns7:RNObjects>
               <ns7:ProcessingOptions>
                  <ns7:SuppressExternalEvents>false</ns7:SuppressExternalEvents>
                  <ns7:SuppressRules>false</ns7:SuppressRules>
               </ns7:ProcessingOptions>
            </ns7:Create>
         </soapenv:Body>
      </soapenv:Envelope>
      But there may be a way to somehow create the associated contact directly as Incident.PrimaryContact. I wasn't able to do it. This would also apply to ConnectPHP I think.
    • Sebastiaan Draaisma

      Thanks Vlad (Vlad D?)

      That seems to do the trick :-)