Powershell - POST to resource field

Powershell - POST to resource field

I am trying to post a value to a resource field and can't seem to do so. the purpose of the script is to take two fields, do some math and then post back a total cost

While there is more to the script that preceeds this I am hoping someone can tell me what I wrong syntactically with the inputdata

when I write to the host I am getting the right values from the variables I am puling from other resource fields; however, I can't seem to post $totalcost to the resource field

Any advice on this would be appreciated


$inputData = @"
{
"operation":{
"details": {
"resources": {
"Costs": {
"Total_Cost": "$totalcost"
}
}
}
}
}
"@


$APILINK="$($SDlink)/sdpapi/request/$($ticket)?"

$postParams = @{INPUT_DATA=$($inputData);OPERATION_NAME='EDIT_REQUEST';TECHNICIAN_KEY=$APIKey;format='json'}
$message="";

try{
$Response = Invoke-WebRequest -Uri $APILink -Method POST -Body $postParams -TimeoutSec 10 -UseBasicParsing
$Response = $response.Content | ConvertFrom-json
$Message = $Response.operation.result.status+"-"+$Response.operation.result.message;
}
catch{
$message = "Error + $($_.exception.Message)";
}
write-host $apilink "," $message ",Added: " $totalcost, $totalpieces, $costperpiece


                  New to ADSelfService Plus?