Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

XML Handling in REST createaccountJSON

aidanryan
Regular Contributor
Regular Contributor

Hello,

We are trying to create an account on our REST connection, and one of the fields needed in the body of the POST request is "sessionKey" (token). We are having trouble when it comes to populating however, and receive this error:

 

 

Spoiler
arsTasks.provisioningComments {"auditDetails":{"call1":[{"headers":null,"message":{"string":{"xmlns":"http://www.app.com/","content":"ERROR - App is unable to identify you. Please log in again.\\r\\n\\r\\nIf this problem persists contact App Support."}},"statusCode":200,"description":null,"status":"Failed"}]}

Here is our current createaccountJSON:

 

 

Spoiler
{
    "accountIdPath": "accountName",
    "dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX",
    "responseColsToPropsMap": {
        "accountID": "call1.message.Id~#~char",
        "customproperty1": "call1.message.Email~#~char",
        "name": "call1.message.Id~#~char",
        "status": "call1.message.Active~#~char"
    },
    "call": [
        {
            "name": "call1",
            "connection": "acctAuth",
            "showResponse": true,
            "url": "https://companytest.targetapp.com/tbws/adrBook.asmx/SaveContact",
            "httpMethod": "POST",
            "httpParams": "{\"sessionKey\":\"${access_token}\",\"contactDetailsXml\":\"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?> <DataSet xmlns=\\\"http://www.targetapp.com/\\\"> <xs:schema id=\\\"NewDataSet\\\" xmlns=\\\"\\\" xmlns:xs=\\\"http://www.w3.org/2001/XMLSchema\\\" xmlns:msdata=\\\"urn:schemas-microsoft-com:xml-msdata\\\"> <xs:element name=\\\"NewDataSet\\\" msdata:IsDataSet=\\\"true\\\" msdata:UseCurrentLocale=\\\"true\\\"> <xs:complexType> <xs:choice minOccurs=\\\"0\\\" maxOccurs=\\\"unbounded\\\"> <xs:element name=\\\"fContactCustom\\\"> <xs:complexType> <xs:sequence> <xs:element name=\\\"Int_Key\\\" type=\\\"xs:int\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Int_Adr\\\" type=\\\"xs:int\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"DISTRICT\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name=\\\"fContact\\\"> <xs:complexType> <xs:sequence> <xs:element name=\\\"Int_Key\\\" type=\\\"xs:int\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"CompanyId\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Company\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Id\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Title\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"FirstName\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"LastName\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Address1\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Address2\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"PostalAdr\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Position\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"City\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"State\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"PostCode\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Country\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"PhoneBH\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"PhoneMob\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Fax\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Email\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Internet\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Remarks\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Type\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Int_Comp\\\" type=\\\"xs:int\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"NotifyType\\\" type=\\\"xs:int\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"ADUserName\\\" type=\\\"xs:string\\\" minOccurs=\\\"0\\\" xmlns:xs=\\\"http://www.w3.org/2001/XMLSchema\\\" /> <xs:element name=\\\"AdrType\\\" type=\\\"xs:int\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Int_Method\\\" type=\\\"xs:int\\\" minOccurs=\\\"0\\\" /> <xs:element name=\\\"Active\\\" type=\\\"xs:int\\\" minOccurs=\\\"0\\\" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> </xs:schema> <diffgr:diffgram xmlns:msdata=\\\"urn:schemas-microsoft-com:xml-msdata\\\" xmlns:diffgr=\\\"urn:schemas-microsoft-com:xml-diffgram-v1\\\"> <NewDataSet xmlns=\\\"\\\"> <fContact diffgr:id=\\\"fContact1\\\" msdata:rowOrder=\\\"0\\\"> <Int_Key>0</Int_Key> <CompanyId>company</CompanyId> <Company>company</Company> <Id>${task.accountname}</Id> <Title></Title> <FirstName>${user.lastname}</FirstName> <LastName>${user.lastname}</LastName> <Address1></Address1> <Address2></Address2> <PostalAdr></PostalAdr> <Position>Test Contact</Position> <City></City> <State></State> <PostCode></PostCode> <Country></Country> <PhoneBH></PhoneBH> <PhoneMob></PhoneMob> <Fax></Fax> <Email>${user.email}</Email> <Internet /> <Remarks /> <Type /> <Int_Comp>2</Int_Comp> <NotifyType>1</NotifyType> <ADUserName></ADUserName> <AdrType>0</AdrType> <Int_Method>12</Int_Method> <Active>1</Active> </fContact> <fContactCustom diffgr:id=\\\"fContactCustom1\\\" msdata:rowOrder=\\\"0\\\"> <Int_Key>0</Int_Key> <Int_Adr>0</Int_Adr> <DISTRICT></DISTRICT> </fContactCustom> </NewDataSet> </diffgr:diffgram> </DataSet>\",\"userToBeDuplicated\":\"0\",\"sendWelcomeNotice\":\"false\",\"globalAdrBookAction\":\"NONE\",\"grantDocAccess\":\"false\"}",
            "httpHeaders": {
                "Authorization": "${access_token}"
            },
            "httpContentType": "application/x-www-form-urlencoded",
            "successResponses": [{}]
        }
    ]
}

Here is the required XML format for contactDetailsXml:

 

 

Spoiler
<?xml version="1.0" encoding="utf-8"?> <DataSet xmlns="http://www.targetapp.com/"> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="fContactCustom"> <xs:complexType> <xs:sequence> <xs:element name="Int_Key" type="xs:int" minOccurs="0" /> <xs:element name="Int_Adr" type="xs:int" minOccurs="0" /> <xs:element name="DISTRICT" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="fContact"> <xs:complexType> <xs:sequence> <xs:element name="Int_Key" type="xs:int" minOccurs="0" /> <xs:element name="CompanyId" type="xs:string" minOccurs="0" /> <xs:element name="Company" type="xs:string" minOccurs="0" /> <xs:element name="Id" type="xs:string" minOccurs="0" /> <xs:element name="Title" type="xs:string" minOccurs="0" /> <xs:element name="FirstName" type="xs:string" minOccurs="0" /> <xs:element name="LastName" type="xs:string" minOccurs="0" /> <xs:element name="Address1" type="xs:string" minOccurs="0" /> <xs:element name="Address2" type="xs:string" minOccurs="0" /> <xs:element name="PostalAdr" type="xs:string" minOccurs="0" /> <xs:element name="Position" type="xs:string" minOccurs="0" /> <xs:element name="City" type="xs:string" minOccurs="0" /> <xs:element name="State" type="xs:string" minOccurs="0" /> <xs:element name="PostCode" type="xs:string" minOccurs="0" /> <xs:element name="Country" type="xs:string" minOccurs="0" /> <xs:element name="PhoneBH" type="xs:string" minOccurs="0" /> <xs:element name="PhoneMob" type="xs:string" minOccurs="0" /> <xs:element name="Fax" type="xs:string" minOccurs="0" /> <xs:element name="Email" type="xs:string" minOccurs="0" /> <xs:element name="Internet" type="xs:string" minOccurs="0" /> <xs:element name="Remarks" type="xs:string" minOccurs="0" /> <xs:element name="Type" type="xs:string" minOccurs="0" /> <xs:element name="Int_Comp" type="xs:int" minOccurs="0" /> <xs:element name="NotifyType" type="xs:int" minOccurs="0" /> <xs:element name="ADUserName" type="xs:string" minOccurs="0" xmlns:xs="http://www.w3.org/2001/XMLSchema" /> <xs:element name="AdrType" type="xs:int" minOccurs="0" /> <xs:element name="Int_Method" type="xs:int" minOccurs="0" /> <xs:element name="Active" type="xs:int" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> </xs:schema> <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"> <NewDataSet xmlns=""> <fContact diffgr:id="fContact1" msdata:rowOrder="0"> <Int_Key>0</Int_Key> <CompanyId>company</CompanyId> <Company>company</Company> <Id>ATest4</Id> <Title></Title> <FirstName>User</FirstName> <LastName>Test</LastName> <Address1></Address1> <Address2></Address2> <PostalAdr></PostalAdr> <Position>Test Contact</Position> <City></City> <State></State> <PostCode></PostCode> <Country></Country> <PhoneBH></PhoneBH> <PhoneMob></PhoneMob> <Fax></Fax> <Email>User.Test4@company.com</Email> <Internet /> <Remarks /> <Type /> <Int_Comp>2</Int_Comp> <NotifyType>1</NotifyType> <ADUserName></ADUserName> <AdrType>0</AdrType> <Int_Method>12</Int_Method> <Active>1</Active> </fContact> <fContactCustom diffgr:id="fContactCustom1" msdata:rowOrder="0"> <Int_Key>0</Int_Key> <Int_Adr>0</Int_Adr> <DISTRICT></DISTRICT> </fContactCustom> </NewDataSet> </diffgr:diffgram> </DataSet>

This is the working call I have in Insomnia/Postman:

 

aidanryan_1-1729620792965.png

 

The expected response from a successful creation is this:

 

Spoiler
<?xml version="1.0" encoding="utf-8"?>
<string
	xmlns="http://www.targetapp.com/">#####
</string>

When I attempt to hardcode the token for sessionKey, I get this error:

 

 

Spoiler
{
    "call1": {
        "headers": {
            "Strict-Transport-Security": "max-age=86400; includeSubDomains",
            "Cache-Control": "private, max-age=0",
            "Server": "Microsoft-IIS/10.0",
            "Access-Control-Allow-Origin": "*",
            "X-AspNet-Version": "4.0.30319",
            "Content-Length": "216",
            "Date": "Tue, 22 Oct 2024 18:59:01 GMT",
            "Content-Type": "text/xml; charset=utf-8",
            "X-Powered-By": "ASP.NET"
        },
        "message": {
            "string": {
                "xmlns": "http://www.targetapp.com/",
                "content": "ERROR - ERROR - App encountered an unexpected error. If this problem persists, please contact app Support."
            }
        },
        "statusCode": 200,
        "description": null
    }
}

Is there something I need to be doing with XML handling in the JSON body? I added proper escaping to it as well. I keep getting this error in the logs as well:

Spoiler
java.lang.NullPointerException: Cannot get property 'id' on null object at com.saviynt.provisoning.rest.RestProvisioningService.getCommonBindingMappings(RestProvisioningService.groovy:12129) at com.saviynt.provisoning.rest.RestProvisioningService$_createAccount_closure14.doCall(RestProvisioningService.groovy:2172) at com.saviynt.provisoning.rest.RestProvisioningService.createAccount(RestProvisioningService.groovy:2032) at com.saviynt.ecm.services.ArsTaskService.createAccountTarget(ArsTaskService.groovy:12096) at com.saviynt.ecm.services.ArsTaskHelperService$_whenTaskTypeIsThreeNewAccountAccess_closure50.doCall(ArsTaskHelperService.groovy:3175) at com.saviynt.ecm.services.ArsTaskHelperService.whenTaskTypeIsThreeNewAccountAccess(ArsTaskHelperService.groovy:3166) at com.saviynt.ecm.services.ArsTaskHelperService$_completeAutoProvTasksUpgraded_closure1.doCall(ArsTaskHelperService.groovy:177) at com.saviynt.ecm.services.ArsTaskHelperService.completeAutoProvTasksUpgraded(ArsTaskHelperService.groovy:162) at MultipleProvisioningJob.execute(MultipleProvisioningJob.groovy:222) at org.quartz.core.JobRunShell.run(JobRunShell.java:199) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)

The accounts keep getting made in Saviynt, but won't create on the target app.

 

7 REPLIES 7

rushikeshvartak
All-Star
All-Star
  • Does connection JSON is working ?

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

@rushikeshvartak Yeah, took a while, but we have our Connection JSON working along with the account import. I can also verify the token works in the "testConnectionParams" and because it works for the account import.

 

Spoiler
{
  "authentications": {
    "acctAuth": {
      "authType": "oauth2",
      "url": "https://##############/tbws/session.asmx/Logon?UserID=APP.SVC&CompanyID=company&Password=###########&ProjNo=GAB&connectingProduct=SAVIYNT",
      "httpMethod": "GET",
      "httpParams": {},
      "httpHeaders": {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      "httpContentType": "application/x-www-form-urlencoded",
      "expiryError": "",
      "retryFailureStatusCode": [],
      "authError": [
        "ERROR - Invalid User ID Company ID or Password.",
        "ERROR - Invalid Project Number.",
        "200"
      ],
      "errors": [],
      "timeOutError": "Read timed out",
      "errorPath": "string",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "string.content",
      "testConnectionParams": {
        "http": {
          "url": "https://##############/tbws/adrBook.asmx/ListContacts?SessionKey=${access_token}&contactFilter=%7B%22fContactFilter3%22%3A%20%5B%7B%22Field%22%3A%20%22FirstName%22,%22Condition%22%3A%20%22NOTLIKE%22,%22Value%22%3A%20%22FooFighter%22%7D%5D%7D&orderBy=FirstName&startRowPosition=0&noOfRows=1&companyIntKey=0",
          "httpContentType": "application/json",
          "httpMethod": "GET"
        },
        "successResponsePath": "",
        "errors": [],
        "errorPath": "string[0]"
      }
    }
  }
}

NM
Honored Contributor III
Honored Contributor III

@aidanryan if you try to send authroization in header and session key in body what behaviour do you see.

Check via postman once.


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

aidanryan
Regular Contributor
Regular Contributor

@NM I get the expected response of an account being made in the target application. It doesn't care that the token is in the header and just ignores it. 

aidanryan_0-1729687819790.pngaidanryan_1-1729687852817.png

 

Can you share curl command


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

@rushikeshvartak Sure thing!

 

Spoiler
curl --request POST \
  --url https://###########com/tbws/adrBook.asmx/SaveContact \
  --header 'Authorization: ##########################' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data sessionKey=########################### \
  --data 'contactDetailsXml=<?xml version="1.0" encoding="utf-8"?> <DataSet xmlns="http://www.targetapp.com/"> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="fContactCustom"> <xs:complexType> <xs:sequence> <xs:element name="Int_Key" type="xs:int" minOccurs="0" /> <xs:element name="Int_Adr" type="xs:int" minOccurs="0" /> <xs:element name="DISTRICT" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="fContact"> <xs:complexType> <xs:sequence> <xs:element name="Int_Key" type="xs:int" minOccurs="0" /> <xs:element name="CompanyId" type="xs:string" minOccurs="0" /> <xs:element name="Company" type="xs:string" minOccurs="0" /> <xs:element name="Id" type="xs:string" minOccurs="0" /> <xs:element name="Title" type="xs:string" minOccurs="0" /> <xs:element name="FirstName" type="xs:string" minOccurs="0" /> <xs:element name="LastName" type="xs:string" minOccurs="0" /> <xs:element name="Address1" type="xs:string" minOccurs="0" /> <xs:element name="Address2" type="xs:string" minOccurs="0" /> <xs:element name="PostalAdr" type="xs:string" minOccurs="0" /> <xs:element name="Position" type="xs:string" minOccurs="0" /> <xs:element name="City" type="xs:string" minOccurs="0" /> <xs:element name="State" type="xs:string" minOccurs="0" /> <xs:element name="PostCode" type="xs:string" minOccurs="0" /> <xs:element name="Country" type="xs:string" minOccurs="0" /> <xs:element name="PhoneBH" type="xs:string" minOccurs="0" /> <xs:element name="PhoneMob" type="xs:string" minOccurs="0" /> <xs:element name="Fax" type="xs:string" minOccurs="0" /> <xs:element name="Email" type="xs:string" minOccurs="0" /> <xs:element name="Internet" type="xs:string" minOccurs="0" /> <xs:element name="Remarks" type="xs:string" minOccurs="0" /> <xs:element name="Type" type="xs:string" minOccurs="0" /> <xs:element name="Int_Comp" type="xs:int" minOccurs="0" /> <xs:element name="NotifyType" type="xs:int" minOccurs="0" /> <xs:element name="ADUserName" type="xs:string" minOccurs="0" xmlns:xs="http://www.w3.org/2001/XMLSchema" /> <xs:element name="AdrType" type="xs:int" minOccurs="0" /> <xs:element name="Int_Method" type="xs:int" minOccurs="0" /> <xs:element name="Active" type="xs:int" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> </xs:schema> <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"> <NewDataSet xmlns=""> <fContact diffgr:id="fContact1" msdata:rowOrder="0"> <Int_Key>0</Int_Key> <CompanyId>COMPANY</CompanyId> <Company>Company</Company> <Id>UTest4</Id> <Title></Title> <FirstName>User</FirstName> <LastName>Test</LastName> <Address1></Address1> <Address2></Address2> <PostalAdr></PostalAdr> <Position>Test Contact</Position> <City></City> <State></State> <PostCode></PostCode> <Country></Country> <PhoneBH></PhoneBH> <PhoneMob></PhoneMob> <Fax></Fax> <Email>User.Test4@Company.com</Email> <Internet /> <Remarks /> <Type /> <Int_Comp>2</Int_Comp> <NotifyType>1</NotifyType> <ADUserName></ADUserName> <AdrType>0</AdrType> <Int_Method>12</Int_Method> <Active>1</Active> </fContact> <fContactCustom diffgr:id="fContactCustom1" msdata:rowOrder="0"> <Int_Key>0</Int_Key> <Int_Adr>0</Int_Adr> <DISTRICT></DISTRICT> </fContactCustom> </NewDataSet> </diffgr:diffgram> </DataSet>' \
  --data userToBeDuplicated=0 \
  --data sendWelcomeNotice=false \
  --data globalAdrBookAction=NONE \
  --data grantDocAccess=false

try adding 

              "Accept": "application/xml",

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.