We are delighted to share our new EIC Delivery Methodology for efficiently managing Saviynt Implementations and delivering quick time to value. CLICK HERE.

XML Response Body in REST Connector - Account Import

naveenss
All-Star
All-Star

Hi,

We have a requirement to integrate one of the applications using the REST Connector with Saviynt.

The challenge here is, the API endpoint has the request body in XML format and it is connecting to a SOAP endpoint. And the response body received from the target application is also in XML format.

We are able to achieve the account & access provisioning using the REST connector's createAccountJSON and AddAccessJSON.

But during the account import, the response received from the target is not parsed as a JSON body. Below is the responseText that is found in the logs. FYI, during createAccountJSON and AddAccessJSON, the response body(which is actually an XML) is converted to a JSON body by Saviynt.

2022-05-31/06:48:42.748 [{}] [quartzScheduler_Worker-3]  DEBUG rest.RestProvisioningService - Got Webservice API Response: [headers:[Cache-Control: private, max-age=0,no-store, Pragma: no-cache, Content-Type: application/soap+xml; charset=utf-8, Server: , Strict-Transport-Security: max-age=7776000; includeSubDomains, X-XSS-Protection: 1; mode=block, X-Content-Type-Options: nosniff, Referrer-Policy: strict-origin-when-cross-origin, X-Frame-Options: DENY, Date: Tue, 31 May 2022 06:48:41 GMT, Connection: close, Content-Length: 2117], responseText:<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://<url>.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://<url>.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><env:Header xmlns:env="http://www.w3.org/2003/05/soap-envelope"><wsa:Action>RetrieveResponse</wsa:Action><wsa:MessageID>urn:uuid:b6c5a490-0f91--ab6c-4cd3800b6b7f</wsa:MessageID><wsa:RelatesTo>urn:uuid:7e0cca04-57bd-4481-864c-6ea8039d2ea0</wsa:RelatesTo><wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To><wsse:Security><wsu:Timestamp wsu:Id="Timestamp-76d5634a-65c5-4e14-9a87-c84a0f2812c2"><wsu:Created>2022-05-31T06:48:42Z</wsu:Created><wsu:Expires>2022-05-31T06:53:42Z</wsu:Expires></wsu:Timestamp></wsse:Security></env:Header><soap:Body><RetrieveResponseMsg xmlns="http://<instanceURL>/wsdl/partnerAPI"><OverallStatus>OK</OverallStatus><RequestID>fc60fe66-c5ab-46be-8f97</RequestID><Results xsi:type="AccountUser"><Client><ID>7297301</ID></Client><PartnerKey xsi:nil="true" /><ID>1234567</ID><ObjectID xsi:nil="true" /><UserID>userid1</UserID><Name>userid2</Name><Email>userid1@abc.com</Email><ActiveFlag>true</ActiveFlag><Delete>0</Delete><IsAPIUser>false</IsAPIUser><Roles><Role><Client><ID>123456</ID><CreatedBy>12345</CreatedBy><ModifiedBy>12345</ModifiedBy><EnterpriseID>12345</EnterpriseID></Client><PartnerKey xsi:nil="true" /><CreatedDate>2022-05-24T09:16:36.6</CreatedDate><ModifiedDate>2022-05-24T09:16:36.6</ModifiedDate><ObjectID>55010331-b845-48df37d1df5a</ObjectID><CustomerKey>Individual role for 123455</CustomerKey><Name>Individual role for 123456</Name><Description>Individual role for 12345</Description><IsPrivate>true</IsPrivate><IsSystemDefined>false</IsSystemDefined></Role></Roles></Results></RetrieveResponseMsg></soap:Body></soap:Envelope>, cookies:[], statusCode:200]

Note: We have explored the option of using the Saviynt' s SOAP connector. However, the challenge here is, the token endpoint used to generate the access token is a REST authorization service. Hence the possibility of using the SOAP connector is ruled out.

Please let us know if anyone has encountered a similar scenario to import accounts using REST connector having a XML response body. Any help is much appreciated. Thank you very much!

Regards,
Naveen

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.
8 REPLIES 8

Rajesh-R
Saviynt Employee
Saviynt Employee

Hi Naveen,

Greetings, 

As per the Saviynt REST Connector Documentation, There is a mentioning about this,

7. Unable to consume the API response in the XML format

Cause: The response might be invalid.

Resolution: To resolve this issue, convert the xml response to the JSON format using any available xml-JSON converter. If the converter returns that the response is in valid JSON format, the XML response can be consumed by the REST connector.

Link: https://saviynt.freshdesk.com/a/solutions/articles/43000521736

To support this, there are a few recommendations, we propose:

  • Use any online XML to JSON Converter and try to convert the XML Response to a JSON Format. If this is a Valid JSON, the Saviynt REST Connector will work.
  • If we take the above mentioned response is a valid SOAP Response, when converted into a JSON Format it will change like below.

 

{
  "Envelope": {
    "Header": {
      "Action": "RetrieveResponse",
      "MessageID": "urn:uuid:b6c5a490-0f91--ab6c-4cd3800b6b7f",
      "RelatesTo": "urn:uuid:7e0cca04-57bd-4481-864c-6ea8039d2ea0",
      "To": "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
      "Security": {
        "Timestamp": {
          "Created": "2022-05-31T06:48:42Z",
          "Expires": "2022-05-31T06:53:42Z"
        }
      }
    },
    "Body": {
      "RetrieveResponseMsg": {
        "OverallStatus": "OK",
        "RequestID": "fc60fe66-c5ab-46be-8f97",
        "Results": {
          "Client": {
            "ID": 7297301
          },
          "PartnerKey": "",
          "ID": 1234567,
          "ObjectID": "",
          "UserID": "userid1",
          "Name": "userid2",
          "Email": "userid1@abc.com",
          "ActiveFlag": true,
          "Delete": 0,
          "IsAPIUser": false,
          "Roles": {
            "Role": {
              "Client": {
                "ID": 123456,
                "CreatedBy": 12345,
                "ModifiedBy": 12345,
                "EnterpriseID": 12345
              },
              "PartnerKey": "",
              "CreatedDate": "2022-05-24T09:16:36.6",
              "ModifiedDate": "2022-05-24T09:16:36.6",
              "ObjectID": "55010331-b845-48df37d1df5a",
              "CustomerKey": "Individual role for 123455",
              "Name": "Individual role for 123456",
              "Description": "Individual role for 12345",
              "IsPrivate": true,
              "IsSystemDefined": false
            }
          }
        }
      }
    }
  }
}

 

  • The Mapping should be based on the elements in the JSON format.
  • An Another recommendation is to use "Accept: application/json" in the header, so that if the application supports a JSON response, we will straight away get a JSON Response directly from the target. You can validate this in postman and chk if the API is giving a JSON response, upon adding this field in the Headers.

Kindly try out the above mentioned recommendations share with us the ImportAccountJSON if you are still not able to proceed. Hope this helps.

 


Thanks
Rajesh Ramalingam
Saviynt India

Hi Rajesh,

Thanks for your response!

Just to let you know, we have already performed all the possible solutions (as suggested in the REST Connector guide). The XML response received is a valid since the XML-JSON converter is not throwing any errors.

Regarding adding the "Accept":"application/json" in the request header, I even tried this option but with no luck.

Just to highlight, the response we are getting in case of createAccountJSON, addAccessJSON, revokeAccessJSON is no different that we are seeing in case of account import. However, as I have mentioned before Saviynt is converting the XML response body to a JSON format in all other cases (even though I'm not passing the "application/json" as a header) except for the account import case.

Would be interesting and helpful to know if there are any other possibilities of converting the responseText using a groovy code in the JSON (if this is possible and recommended).

Thanks again!

Regards,

Naveen

 

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

naveenss
All-Star
All-Star

Sharing the ImportAccountEntJSON if that helps:

{
  "accountParams": {
    "connection": "acctAuth",
    "processingType": "SequentialAndIterative",
    "call": {
      "call1": {
        "callOrder": 0,
        "http": {
          "url": "https://{soap_endpoint_url}/Service.asmx",
          "httpParams": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:u=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\"><s:Header><a:Action s:mustUnderstand=\"1\">Retrieve</a:Action><a:MessageID>urn:uuid:7e0cca04-57bd-4481-864c-6ea8039d2ea0</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand=\"1\">https://{soap_endpoint_url}/Service.asmx</a:To><fueloauth>${access_token}</fueloauth></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><RetrieveRequestMsg xmlns=\"http://{instance_url}/wsdl/partnerAPI\"><RetrieveRequest><Filter xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"SimpleFilterPart\"><Property>Name</Property><SimpleOperator>equals</SimpleOperator><Value>abcd</Value></Filter><QueryAllAccounts>true</QueryAllAccounts><ObjectType>AccountUser</ObjectType><Properties>ID</Properties><Properties>ActiveFlag</Properties><Properties>Email</Properties><Properties>IsAPIUser</Properties><Properties>Roles</Properties><Properties>Name</Properties><Properties>UserID</Properties></RetrieveRequest></RetrieveRequestMsg></s:Body></s:Envelope>",
          "httpHeaders": {
            "Content-Type": "text/xml",
            "Accept": "application/json"
          },
          "httpContentType": "text/xml",
          "httpMethod": "POST"
        },
        "listField": "soap:Body.RetrieveResponseMsg.Results",
        "keyField": "accountID",
        "statusConfig": {
          "active": "true",
          "inactive": "false"
        },
        "colsToPropsMap": {
          "name": "Email~#~char",
          "accountID": "UserID~#~char",
          "customproperty1": "Name~#~char",
          "customproperty2": "NotificationEmailAddress~#~char"
        }
      }
    }
  }
}

 

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

Rajesh-R
Saviynt Employee
Saviynt Employee

Hi Naveen,

I have made some Minor Tweaks. Check if this works.

Also the response doesnt contain any Element called NotificationEmailAddress. Please verify

 

{
  "accountParams": {
    "connection": "acctAuth",
    "processingType": "SequentialAndIterative",
    "call": {
      "call1": {
        "callOrder": 0,
        "http": {
          "url": "https://{soap_endpoint_url}/Service.asmx",
          "httpParams": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:u=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\"><s:Header><a:Action s:mustUnderstand=\"1\">Retrieve</a:Action><a:MessageID>urn:uuid:7e0cca04-57bd-4481-864c-6ea8039d2ea0</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand=\"1\">https://{soap_endpoint_url}/Service.asmx</a:To><fueloauth>${access_token}</fueloauth></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><RetrieveRequestMsg xmlns=\"http://{instance_url}/wsdl/partnerAPI\"><RetrieveRequest><Filter xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"SimpleFilterPart\"><Property>Name</Property><SimpleOperator>equals</SimpleOperator><Value>abcd</Value></Filter><QueryAllAccounts>true</QueryAllAccounts><ObjectType>AccountUser</ObjectType><Properties>ID</Properties><Properties>ActiveFlag</Properties><Properties>Email</Properties><Properties>IsAPIUser</Properties><Properties>Roles</Properties><Properties>Name</Properties><Properties>UserID</Properties></RetrieveRequest></RetrieveRequestMsg></s:Body></s:Envelope>",
          "httpHeaders": {
            "Content-Type": "application/xml"
          },
          "httpContentType": "application/xml",
          "httpMethod": "POST"
        },
        "listField": "Body.RetrieveResponseMsg.Results",
        "keyField": "accountID",
        "colsToPropsMap": {
          "name": "Email~#~char",
          "accountID": "UserID~#~char",
          "customproperty1": "Name~#~char",
          "customproperty2": "NotificationEmailAddress~#~char"
        }
      }
    }
  }
}

 

 


Thanks
Rajesh Ramalingam
Saviynt India

Thanks for your suggestion, Rajesh!

However, changing the Content-Type to application/xml is returning a 415 status code. Same response is returned in postman as well.

2022-06-01/04:52:39.169 [{}] [quartzScheduler_Worker-2]  DEBUG rest.RestProvisioningService - Got Webservice API Response: [headers:[Cache-Control: private,no-store, Pragma: no-cache, Content-Type: text/html, Server: , Strict-Transport-Security: max-age=7776000; includeSubDomains, X-XSS-Protection: 1; mode=block, X-Content-Type-Options: nosniff, Referrer-Policy: strict-origin-when-cross-origin, X-Frame-Options: DENY, Date: Wed, 01 Jun 2022 04:52:38 GMT, Connection: close], responseText:The server cannot service the request because the media type is unsupported., cookies:[], statusCode:415]
2022-06-01/04:52:39.169 [{}] [quartzScheduler_Worker-2]  DEBUG rest.RestProvisioningService - pullObjectsByRest - responseStatusCode ::415

Thanks,

Naveen

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

Rajesh-R
Saviynt Employee
Saviynt Employee

Naveen,

Thanks for coming back. 

Could you just change the list field to 

"listField": "Body.RetrieveResponseMsg.Results",

In your JSON, It is mentioned below:

 "listField": "soap:Body.RetrieveResponseMsg.Results",

Bring the Content-Type back to text/xml

 

 


Thanks
Rajesh Ramalingam
Saviynt India

Thanks for the suggestion, Rajesh! Tried this option as well. However, the objectList is still coming as null and the connector is unable to detect the response. 

pullObjectsByRest - objectList.size : null

Tried other option like below. Still no luck.

 

"listField":"Results"

 

 Regards,

Naveen

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

Rajesh-R
Saviynt Employee
Saviynt Employee

Hi Naveen,

If the objectList.size is null then the response itself is not coming back to Saviynt. Could you share the complete Import Log Extract for this? It would help in debugging the issue further.

 


Thanks
Rajesh Ramalingam
Saviynt India