Jenkins Powershell API call to trigger a job

Team,

I am trying to trigger a Jenkins job via the api.

I am able to generate a crumb and have it returned but I am getting this error

" HTTP ERROR 403 No valid crumb was included in the request"

Any suggestion 's on this would be highly appreciated. Thanks!


$API_User = "user"
$API_Pass =  "pass"
$API_URL = "localhost"
$API_Port = "8080"
$API_Job = "test"

$h = @{}
$h.Add('Authorization', 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$(${API_User}):$(${API_Pass})")))

$Params = @{uri = "http://${API_URL}:${API_Port}/crumbIssuer/api/json";
        Method = 'Get';
        Headers = $h;}
$API_Crumb = Invoke-RestMethod @Params

$h.Add('Jenkins-Crumb', $API_Crumb.crumb)
$Params['uri'] = "http://${API_URL}:${API_Port}/job/${API_Job}/build"
$Params['Method'] = 'Post'
$Params['Headers'] = $h

Invoke-RestMethod @Params