Skip to main content

Last updated: 2024-06-07


Request/Response


In this topic:


Overview


Client applications send a request XML to SmartIntegrator and receive a response in XML format. The request XML includes actions, data and authentication information. The response XML from SmartIntegrator includes status and result data.


XML requests and responses contain two components: a header and content. The header contains authentication information.


Once you understand how requests are formatted, refer to the operations you can carry out using SmartIntegrator.


Request XML


The following example request uses the get operation to retrieve a contact's first and last names:


XML
<request version="1.0">
  <header>
     <office/>
     <user/>
     <password/>
  </header>
  <get>
     <Contact id="Contact.1.1">
        <LastName/>
        <FirstName/>
     </Contact>
  </get>
</request>

Important: The header element of every request must include the office, user and password as empty elements, as shown in the example above. However, to simplify examples elsewhere in this documentation, the abbreviation <header>...</header> is used.


Header Variable Values


All requests send during development of your integration must contain the headers variables described in the table below. These values are pre-filled in the Postman collection you received during the onboarding process.


Header VariableDescriptionRequired
sitenameSmartOffice site nameYes
usernameSmartOffice user name in the format <SiteName>_<OfficeName>_<UserName> (the client needs to know for which office and user the request needs to execute)Yes
api-keyKey (learn more)Yes
api-secretKey (learn more)Yes

The API gateway processes the request XML as a stream. This requires that the header be the first child of the root element. Otherwise, the engine will stop processing and an error response XML will be returned.


Authentication


Authentication information is stored in the Headers section in the Postman collection you received during the onboarding process.


Transaction Element


Each coherent operation can be specified within a single transaction element. A request can contain multiple transactions. The following example shows the basic structure of a request containing a transaction element and two operations, insert and update.


XML
<request>
<header>...</header>
<transaction>
  <insert>...</insert>
  <update>...</update>
</transaction>
</request>

Using the transaction element in a request is optional. If no transaction is required, the transaction element can be omitted, and the query can be sent directly with the query element at the same level as the header.


Use of the transaction element is recommended when you are performing operations (like insert or update) that can cause data issues if they are interrupted by connection problems or other issues. SmartIntegrator processes all operations within the transaction element before making any changes to the database.


User Attributes


Attributes of key elements (request, header, transaction, insert) included in a request are written back in the response XML. This feature enables a client application to place marks, or "signatures," in the request XML and trace them back through the response XML. In this way, the caller can locate the targets in a response XML stream. Note that user attributes are ignored if added to object and property elements.


In the following example request, traceid and mark are user attributes.


XML
<request version="1.0" traceid="123341254">
  <header>...</header>
  <get mark="abc">
    <Contact id="Contact.65854.3">
      <FullName/>
    </Contact>
  </get>
</request>

SmartIntegrator copies them to the response XML:


XML
<response version="1.0" traceid="123341254">
  <header>
  </header>
  <get mark="abc">
    <Contact id="Contact.65854.3">
      <FullName>Ackerman,Joseph</FullName>
    </Contact>
  </get>
  <!-- Cost 47 mill seconds. -->
</response>

Response XML


The content of an XML response shows the results of actions. The response XML ordinarily has a similar structure as a request XML.


Example:


XML
<response version="1.0">
  <header>
  </header>
  <get>
    <Contact id="Contact.1.1">
      <LastName>Ackerman</LastName>
      <FirstName>Joe</FirstName>
    </Contact>
  </get>
</response>