ACI API 24.1

# 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 IDOL 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 2023 Open Text
Version 24.1 | Last updated December 2023

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: IDOL ACI API 24.1

Topic Title: Process a Response