Click HERE to see how Saviynt Intelligence is transforming the industry. |
10/22/2024 12:19 PM - edited 10/22/2024 12:39 PM
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:
Here is our current createaccountJSON:
{
"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:
<?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:
The expected response from a successful creation is this:
<?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:
{
"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:
The accounts keep getting made in Saviynt, but won't create on the target app.
10/22/2024 01:40 PM
10/22/2024 01:55 PM
@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.
{
"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]"
}
}
}
}
10/22/2024 08:22 PM
@aidanryan if you try to send authroization in header and session key in body what behaviour do you see.
Check via postman once.
10/23/2024 05:49 AM - edited 10/23/2024 05:50 AM
@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.
10/23/2024 05:53 AM
Can you share curl command
10/23/2024 06:06 AM
@rushikeshvartak Sure thing!
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
10/23/2024 06:12 AM
try adding
"Accept": "application/xml",