Powershell invoke-webRequest - The remote server returned an error: (422) Unprocessable Entity

540 Views Asked by At

When I try to create an issue in redmine via the Rest Api using Powershell, I get an error: The remote server returned an error: (422) Unprocessable Entity. In postman, this request is processed correctly.

Here is an example of script:

$Headers = @{ 'X-Redmine-API-key' = '********' }
$Uri = "https://task.test.com/issues.json"
Invoke-RestMethod $Uri -Headers $Headers -Method POST -ContentType 'application/json' -Body '{
    "issue": {
        "project_id": 316,
        "subject": "testProject",
        "priority_id": 4,
        "description": "testTask",
        "assigned_to_id": 1891,
        "custom_fields": [{
                "value": "******",
                "name": "physicalName",
                "id": 5
            },
            {
                "value": "****",
                "name": "***",
                "id": 6
            },
            {
                "value": "****",
                "name": "*****",
                "id": 10
            },
            {
                "value": "****",
                "name": "*****",
                "id": 11
            },
            {
                "value": "0",
                "name": "*******",
                "id": 16
            }
        ]
    }
}'
0

There are 0 best solutions below