I do understand that this question has been asked and answered many times, but I'm getting an error that I've not seen on the forums and I'm hoping someone might know what I'm doing wrong.
So, what am I doing? I am using the Expensify API to automate the provisioning of new hires. I already have a 2,000 line new hire script and I'm just trying to add more SaaS apps to it so I have to do... less.
The cURL request is supposed to look like this:
curl -X POST 'https://integrations.expensify.com/Integration-Server/ExpensifyIntegrations' \
-H 'Expect:' \
-F 'requestJobDescription={
"type": "update",
"credentials": {
"partnerUserID": "_REPLACE_",
"partnerUserSecret": "_REPLACE_"
},
"inputSettings": {
"type": "employees",
"policyID":"0123456789ABCDEF",
"fileType": "csv"
}
}' \
-F 'data=@employeeData.csv'
And my script looks like this:
$expensify_csv = @(
[pscustomobject]@{
EmployeeEmail = $email
ManagerEmail = $mngr_email
Admin = $expensify_admin
ForwardManagerEmail = $fwd_email
}
) | Export-Csv -Path C:\expensify.csv -NoTypeInformation
$expensify_csv = [IO.File]::ReadAllText('C:\expensify.csv');
$json = [ordered]@{
"requestJobDescription" = @{
"type" = "update";
"credentials" = @{
"partnerUserID" = $expensify_id;
"partnerUserSecret" = $expensify_secret;
}
"inputSettings" = @{
"type" = "employees";
"policyID" = "F9CC59BCD4521BB2";
"fileType" = "csv";
}
};
"data" = $expensify_csv
} | ConvertTo-Json -Depth 10
Write-Host $json
$check = Invoke-RestMethod `
-Method Post `
-Uri $expensify_url `
-Body $json `
-ContentType multipart/form-data `
Write-Host $check
exit
And the error that is being returned:
Invoke-RestMethod :
Error
body{
font-family: Arial;
}
pre{
padding: 5px;
background-color: #ddd;
border-top: 2px solid #999;
}
An error occurred
Internal Server Error
It looks like the error has something to do with CSS? I have no idea though. Very strange. I've been battling this API for some time now and I'd appreciate any feedback!