ACI API 25.4
ACI API Programming Guide

# Process a Response

There are two ways to execute the request, depending on how you want to process the response.

## Obtain and Process an Unparsed Response

The `aciObjectExecuteToString` function returns the server response as an unparsed data buffer:

    char *szResponse = NULL;
    int nResponseLen = 0;
    char *szContentType = NULL;

    aciObjectExecuteToString(pConnection, pCommand, &szResponse, &nResponseLen, &szContentType);

    // For most actions, szResponse now holds the raw xml and szContentType will be "application/xml"
    // Process the xml in whatever way you wish now (e.g. third-party XML processing API)

    // Remember to tidy up afterwards
    free(szResponse);
    free(szContentType);

## Obtain and Process a Parsed Response

The `aciObjectExecute` function returns a `t_aciObject` that holds a parsed representation of the XML, which you can manipulate by using the `acio` set of functions in the C Knowledge Discovery SDK. For example if the XML returned was from the `UserReadAgentList` action and the following response was retrieved:

    <?xml version="1.0" encoding="UTF-8" ?>
    <autnresponse>
      <action>USERREADAGENTLIST</action>
      <response>SUCCESS</response>
      <responsedata>
      <maxagents>5</maxagents>
      <numagents>2</numagents>
      <agent>Housing</agent>
      <agent>Rock climbing</agent>
      </responsedata>
    </autnresponse>

Then you can obtain the list of agent names for the user as follows:

    // Always need to call aciInit at start of any program using ACI client lib
    aciInit();

    t_aciObject *pResult = NULL;
    char **szAgentNames = NULL;
    aciObjectExecute(pConnection, pCommand, &pResult);

    if (aciObjectCheckforSuccess(pResult))
    {
      // Successful request so find out how many agents this user has
      t_aciObject* pNumAgent = NULL;
      pNumAgent = acioFindFirstOccurrence(pResult, "numagents");
      if(pNumAgent)
      {
        int nNumAgents = 0;
        acioParamGetInt(pNumAgent, ACI_DATA_NODE_VALUE, &nNumAgents);
        if(nNumAgents > 0)
        {
          // This user has agents, construct array to hold names and
          // retrieve agent names from response
          t_aciObject* pAgentName = NULL;
          int nAgent = 0;

          saAgentNames = (char**)malloc(sizeof(char*)*nNumAgents);

          // Find first agent entry
          pAgentName = acioFindFirstOccurrence(pResult, "agent");
          while(pAgentName)
          {
            acioParamGetString(pAgentName, ACI_DATA_NODE_VALUE,
            &saAgentNames[nAgent]);
            // Move to next agent entry
            pAgentName = aciObjectNextEntry(pAgentName);
            nAgent++
          }
        }
      }
    }

    // Remember to tidy up afterwards
    aciObjectDestroy(&pResult);

NOTE: Although it is imperative to free the memory that is associated with an ACI structure in C, you must not free the structure returned by the `acioFindFirstOccurrence` function.

Copyright 2025 Open Text
Version 25.4 | Last updated October 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery ACI API 25.4

Topic Title: Process a Response