SysAid API PowerShell trying to create a SR from template

 
Author
Message
SysAider
1
 
Hello all, can someone let me where the Java message come from? And how to resolve my code? I just wanting to create a SR request from a template.

---My code--
[Net.ServicePointManager]::SecurityProtocol = "Tls, Tls11, Tls12, Ssl3"
$sysAidURI = "https://mycompany.sysaidit.com/api/v1"

Invoke-WebRequest -Uri "$sysAidURI/login" -ContentType "application/json" -Body '{"user_name": "username", "password": "password"}' -Method 'POST' -SessionVariable websession

$Body= '{
"info": [{"key":"due_date", "value":1646857974017},
{"key":"status", "value":2},
{"key":"problem_type","value":"Vulnerability Management"},
{"key":"notes","value":[
{"userName":"sysaid","createDate":1646857974017,"text":"Note 123"}
]},
{"responsibility":35}]
}'

$Data = Invoke-RestMethod -uri "$sysAidURI/sr?type=request&template=145" -WebSession $websession -method POST -ContentType application/json -Body $Body

---And the terminal output----
Invoke-RestMethod : {"status":500,"message":"java.lang.Long cannot be cast to java.lang.String"}
At C:\Users\phamjp\Resilio_Sync\NTT Data Fed\RIC_Scripting\SysAid\create_sr.ps1:19 char:9
+ $Data = Invoke-RestMethod -uri "$sysAidURI/sr?type=request&template=1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

I'm unable create the SR and get this java error...any help will greatly appreciate.
SysAid Product Manager Community Manager
393
 
Hi phamjp,

From a quick peek it look like you have a mismatch on field type in one of the cases but will require further investigation to figure out which and what needs adaptation. If want further support on this it is additional costs, reach out to our lovely Customer Success team for more information about what it includes and costs:
by email: success@sysaid.com or live chat.

Cheers,
Maayan



phamjp wrote:Hello all, can someone let me where the Java message come from? And how to resolve my code? I just wanting to create a SR request from a template.

---My code--
[Net.ServicePointManager]::SecurityProtocol = "Tls, Tls11, Tls12, Ssl3"
$sysAidURI = "https://mycompany.sysaidit.com/api/v1"

Invoke-WebRequest -Uri "$sysAidURI/login" -ContentType "application/json" -Body '{"user_name": "username", "password": "password"}' -Method 'POST' -SessionVariable websession

$Body= '{
"info": [{"key":"due_date", "value":1646857974017},
{"key":"status", "value":2},
{"key":"problem_type","value":"Vulnerability Management"},
{"key":"notes","value":[
{"userName":"sysaid","createDate":1646857974017,"text":"Note 123"}
]},
{"responsibility":35}]
}'

$Data = Invoke-RestMethod -uri "$sysAidURI/sr?type=request&template=145" -WebSession $websession -method POST -ContentType application/json -Body $Body

---And the terminal output----
Invoke-RestMethod : {"status":500,"message":"java.lang.Long cannot be cast to java.lang.String"}
At C:\Users\phamjp\Resilio_Sync\NTT Data Fed\RIC_Scripting\SysAid\create_sr.ps1:19 char:9
+ $Data = Invoke-RestMethod -uri "$sysAidURI/sr?type=request&template=1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

I'm unable create the SR and get this java error...any help will greatly appreciate.