Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Exchange Rest Conenctor issue in dynamic value pass

gwagh
Regular Contributor
Regular Contributor

Hi Team, 

 

Help us to get proper syntax to pass ${user.username} and ${connection.username} , ${connection.password}.

 

Below is the JSON :

 

{
"call": [
{
"name": "call1",
"connection": "acctAuth",
"url": "http://******-savutil01.gaworkdaytest.local/SaviyntApp/PS/ExecutePSScript ",
"httpMethod": "POST",
"httpParams": "{\"script\":\" \u0024name= \u0027\u0024{user.username}\u0027; \u0024cred = New-Object System.Management.Automation.PSCredential -argumentlist \u0027test\\\\user\u0027, (ConvertTo-SecureString \u0027samplepassword\u0027 -AsPlainText -Force); \u0024onprem = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://hostname/PowerShell/  -Credential \u0024cred; Invoke-Command -Session \u0024onprem -scriptBlock {Enable-RemoteMailbox u002DIdentity \u0024using:name -RemoteRoutingAddress \u0024using:name\u0027@domain.com\u0027} \"}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"successResponses": {
"response[9].Objectreturned": [
"Success"
]
},
"unsuccessResponses": {
"response[9].Objectreturned": [
"Failure"
]
}
}
]
}

 

I saw in document there is unicode value for ' - \u0027 and $ - \u0024.

Getting below issue :

 

{"headers":null,"message":{"responseMessage":"\"Exception: Failed error streamThe operation couldn\\u0027t be performed because object \\u0027${user.username}\\u0027 couldn\\u0027t be found on \\u0027TMUE1-DC01.GAWORKDAYTEST.local\\u0027. System.Exception: Failed error streamThe operation couldn\\u0027t be performed because object \\u0027${user.username}\\u0027 couldn\\u0027t be found on \\u0027TMUE1-DC01.GAWORKDAYTEST.local\\u0027.\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName) System.Exception: Failed error streamThe operation couldn\\u0027t be performed because object \\u0027${user.username}\\u0027 couldn\\u0027t be found on \\u0027TMUE1-DC01.GAWORKDAYTEST.local\\u0027. System.Exception: Failed error streamThe operation couldn\\u0027t be performed because object \\u0027${user.username}\\u0027 couldn\\u0027t be found on \\u0027TMUE1-DC01.GAWORKDAYTEST.local\\u0027.\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName)\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName)\""},"statusCode":500,"description":null,"status":"Failed"},{"headers":null,"message":{"responseMessage":"\"Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027$null\\u0027. System.Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027$null\\u0027.\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName) System.Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027$null\\u0027. System.Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027$null\\u0027.\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName)\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName)\""},"statusCode":500,"description":null,"status":"Failed"}]},"call1":{"headers":null,"message":{"responseMessage":"\"Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027${user.username}\\u0027. System.Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027${user.username}\\u0027.\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName) System.Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027${user.username}\\u0027. System.Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027${user.username}\\u0027.\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName)\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName)\""},"statusCode":500,"description":null,"status":"Failed"}}

[This message has been edited by moderator to disable url hyperlink]

13 REPLIES 13

rushikeshvartak
All-Star
All-Star

Share connection json


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Shreya-B
New Contributor
New Contributor

Hi, 

In case $ is used within single quotes, you may not have to use the unicode value.

Please try with the below:-

"httpParams": "{\"script\":\" \u0024name = '${user.username}'; \u0024cred = New-Object System.Management.Automation.PSCredential -argumentlist 'test\\\\user', (ConvertTo-SecureString 'samplepassword' -AsPlainText -Force); \u0024onprem = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://hostname/PowerShell/ -Credential \u0024cred; Invoke-Command -Session \u0024onprem -scriptBlock {Enable-RemoteMailbox u002DIdentity \u0024using:name -RemoteRoutingAddress \u0024using:name'@domain.com'} \"}",

 

ShreyaB_0-1706290952632.png

This may be a possibility for the syntax error.

 

 

yatishtiwari
Regular Contributor
Regular Contributor

Thank you, Shreya.

Now that issue is resolved but new issue arises-

yatishtiwari_0-1706367210012.png

And I think this is because we are initializing the variable $name but using the variable $using:name so the Saviynt is not able to find the usage of $name variable., 

If rather than using $using:name I am trying to use $name then following exception is thrown-

The syntax is not supported by this runspace. This can occur if the runspace is in no-language mode.

Did you defined username & password variables on connection JSON 


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

yatishtiwari
Regular Contributor
Regular Contributor

 Hi Rushikesh,

Yes, Like this-

yatishtiwari_0-1706380644177.png

 

You need to define outside similar like accesstoken. You can share connection json ( masking confidential info) i can help you


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Sample 

{
"authentications": {
"userAuth": {
"authType": "Basic",
"url": "http://xx.xx.xx.corp/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": {},
"httpHeaders": {},
"httpContentType": "text/html",
"properties": {
"userName": "xx",
"password": "xx"
},
"expiryError": "ExpiredAuthenticationToken",
"authError": [
"InvalidAuthenticationToken",
"AuthenticationFailed"
],
"timeOutError": "Read timed out",
"errorPath": "error.code",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Basic",
"accessToken": "Basic xxx",
"username": "rvartak",
"password": "Pass@123",
"testConnectionParams": {
"http": {
"url": "http://xx.xx.xx.corp/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"requestBody": "",
"httpParams": {},
"httpHeaders": {
"contentType": "application/json",
"Authorization": "${accessToken}"
},
"httpContentType": "application/json"
},
"successResponse": [],
"successResponsePath": "responseText",
"errors": [
"fail",
"error",
"false"
],
"errorPath": "responseText"
}
}
}
}

 

in other json use

${connection.username}
${connection.password}


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Thank you, @rushikeshvartak . I will test in the morning and keep u posted.

Hi @rushikeshvartak ,

After changing the connection param as you suggested,. No error is showing in the task, and the retries getting incremented. when I checked the logs it says access token is null.

yatishtiwari_0-1706545078929.png

here is the create account json

{
"accountIdPath": "accountName",
"responseColsToPropsMap": {},
"call": [
{
"name": "call1",
"connection": "acctAuth",
"url": "http://tmue1-savutil01.gaworkdaytest.local/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": "{\"script\": \"\u0024name=\u0027jfoxx\u0027; \u0024cred = New-Object System.Management.Automation.PSCredential -argumentlist \u0027\u0024{connection.username}\u0027, (ConvertTo-SecureString \u0027\u0024{connection.password}\u0027 -AsPlainText -Force); \u0024onprem = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://tmue1-srv03.gaworkdaytest.local/PowerShell/ -Credential \u0024cred; Invoke-Command -Session \u0024onprem -scriptBlock {Enable-RemoteMailbox u002DIdentity \u0024using:name -RemoteRoutingAddress \u0024using:name\u0027@generalatlantictest.mail.onmicrosoft.com\u0027} \"}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"successResponses": {
"response[9].Objectreturned": [
"Success"
]
},
"unsuccessResponses": {
"response[9].Objectreturned": [
"Failure"
]
}
}
]
}

and here is the connection json

{
"authentications": {
"userAuth": {
"authType": "Basic",
"url": "http://savutil01.gaworkdaytest.local/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": {},
"httpHeaders": {},
"httpContentType": "text/html",
"properties": {
"userName": "<domain>\\svcSaviynt",
"password": "password"
},
"expiryError": "ExpiredAuthenticationToken",
"authError": [
"InvalidAuthenticationToken",
"AuthenticationFailed"
],
"timeOutError": "Read timed out",
"errorPath": "error.code",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Basic",
"accessToken": "Basic <token>",
"username": "<domain>\\svcSaviynt",
"password": "password",
"testConnectionParams": {
"http": {
"url": "http://savutil01.gaworkdaytest.local/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"requestBody": "",
"httpParams": {},
"httpHeaders": {
"contentType": "application/json",
"Authorization": "${accessToken}"
},
"httpContentType": "application/json"
},
"successResponse": [],
"successResponsePath": "responseText",
"errors": [
"fail",
"error",
"false"
],
"errorPath": "responseText"
}
}
}
}

 

 

 

Does it works from postman


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Hi @rushikeshvartak ,

Yes its working from Postman.

Hi Have configured the connection like - 

{
"authentications":
{
"acctAuth":
{
"authType": "Basic",
"url": "http://savutil01.local/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": {},
"httpHeaders": {},
"httpContentType": "application/json",
"expiryError": "Couldn't authenticate you",
"authError": [
"Couldn't authenticate you"
],
"timeOutError": "Read timed out",
"errorPath": "error",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Basic",
"username": "domain\\\\username",
"password": "password",
"accessToken": "Basic token"
}
}
}

Now its throwing invalid username or password 

yatishtiwari_0-1706714961398.png

I tried-

"username": "domain\\username",

"username": "domain\\\\username",

"username": "domain\username",

but not working. When I am putting the same in createaccountjson it works but throws some other issue.

Here is my create account json-

{
"accountIdPath": "accountName",
"responseColsToPropsMap": {},
"call": [
{
"name": "call1",
"connection": "acctAuth",
"url": "http://savutil01.local/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": "{\"script\": \"\u0024name=\u0027jfoxx\u0027; \u0024cred = New-Object System.Management.Automation.PSCredential -argumentlist \u0027\u0024{connection.username}\u0027, (ConvertTo-SecureString \u0027\u0024{connection.password}\u0027 -AsPlainText -Force); \u0024onprem = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://srv03.local/PowerShell/ -Credential \u0024cred; Invoke-Command -Session \u0024onprem -scriptBlock {Enable-RemoteMailbox u002DIdentity \u0024using:name -RemoteRoutingAddress \u0024using:name\u0027@test.mail.onmicrosoft.com\u0027} \"}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"successResponses": {
"response[9].Objectreturned": [
"Success"
]
},
"unsuccessResponses": {
"response[9].Objectreturned": [
"Failure"
]
}
}
]
}

Refer https://forums.saviynt.com/t5/identity-governance/integrating-saviynt-variables-with-rest-connector-...


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

yatishtiwari
Regular Contributor
Regular Contributor
Please find below-
 
{
"authentications": 
{
"acctAuth": 
{
"authType": "Basic",
"httpMethod": "POST",
"httpParams": {},
"httpHeaders": {},
"httpContentType": "application/json",
"properties": 
{
"userName": "domain\\svcSaviynt",
"password": "password"
},
"expiryError": "Couldn't authenticate you",
"authError": [
"Couldn't authenticate you"
],
"timeOutError": "Read timed out",
"errorPath": "error",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Basic",
"accessToken": "Basic <token>"
}
}
}