使用时:
$body = @{
Manager = "spmigrationuser@contoso.com" #$item.PMEmail
Name = "some name"
Number = "Some number"
Practice = "Some Practice"
}
$response = Invoke-RestMethod -Method Post -Uri $Url -Body $body -ContentType 'application/json' # -Headers $Headers
或者
$response = Invoke-WebRequest -Method 'POST' -Uri $Url -Body $body -ContentType 'application/json' # -Headers $Headers
ContentType 'application/json' 和 $Headers = @{'Content-Type' = 'application/json' } -Headers $Headers 都
不起作用
错误总是:
"Invoke-WebRequest : {"error":{"code":"InvalidRequestContent","message":"The request content is not valid and could not be deserialized: 'Error parsing NaN value. Path '', line 1, position 1.'."}}"
相同的调用在 Postman 中有效
我使用的是 PS 5.1,我必须有 -ContentType 'application/json' 否则 PS 工作但服务失败
可能是什么问题?