Bad Request 400 Invalid multipart payload format - Invalid body

I’m struggling to bulk import users json file via api/v2/jobs/users-imports endpoint using Powershell script. Could you please point out what am I missing in between?
This is a piece of code resposible for REST call.

$usersDetailsForm = @{
	users=$userDetailsValue
	connection_id=$Auth0DBConnectionId
}

try {
	Invoke-RestMethod "https://$Auth0ApplicationDomain/api/v2/jobs/users-imports" `
		-Method 'POST' `
		-ContentType 'multipart/form-data' `
		-Form $usersDetailsForm `
		-Authentication Bearer `
		-Token $Auth0AccessToken -AllowUnencryptedAuthentication
		| out-null
}
catch {
	$responseErrors.Add(@{
		userId = $ud.user_id
		statusCode = $_.Exception.Response.StatusCode
		exceptionMessage = $_.Exception.Message
		errorMessage = $_.ErrorDetails.Message})
}

Constantly receiving Bad Request with an indication that something is wrong with request body.

However using Users Import/Export extension I managed to upload the same json file without a problem.
The json file has a following content:

    [
    	{
    		"user_id": "1419",
    		"email": "a@a.com",
    		"family_name": "aaadsfsd",
    		"custom_password_hash": {
    			"algorithm": "hmac",
    			"hash": {
    				"value": "CaRYucKkMxetestMrVGG4ko=",
    				"encoding": "utf8",
    				"digest": "sha256",
    				"key": {
    					"value": "test+LtestDmQpCgps102ciuabc=",
    					"encoding": "utf8"
    				}
    			}
    		}
    	},
    	{
    		"user_id": "1421",
    		"email": "team@linx.xyz",
    		"custom_password_hash": {
    			"algorithm": "hmac",
    			"hash": {
    				"value": "CaRYucKkMxetestMrVGG4ko=",
    				"encoding": "utf8",
    				"digest": "sha256",
    				"key": {
    					"value": "test+LtestDmQpCgps102ciuabc=",
    					"encoding": "utf8"
    				}
    			}
    		}
    	}
    ]

Hi @michal.pogorzelski,

Welcome to the Community!

Unfortunately we don’t have a powershell example, but have you looked at this page and tried to match everything?

It might even be easier to build out a python or node script to handle it with the given code.