# Bad Request 400 Invalid multipart payload format - Invalid body

**URL:** <https://community.auth0.com/t/bad-request-400-invalid-multipart-payload-format-invalid-body/51578>\
**Category:** Get Help\
**Tags:** bulk-user-import, import, invalid, user-import\
**Created:** [October 14, 2020, 2:55pm UTC](https://community.auth0.com/t/bad-request-400-invalid-multipart-payload-format-invalid-body/51578 "2020-10-14T14:55:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michal.pogorzelski](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/michal.pogorzelski/32/12765_2.png) [@michal.pogorzelski](https://community.auth0.com/u/michal.pogorzelski)\
**Post date:** [October 14, 2020, 2:55pm UTC](https://community.auth0.com/t/bad-request-400-invalid-multipart-payload-format-invalid-body/51578/1 "2020-10-14T14:55:58Z")

</div>

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"
    				}
    			}
    		}
    	}
    ]

```

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 16, 2020, 8:28pm UTC](https://community.auth0.com/t/bad-request-400-invalid-multipart-payload-format-invalid-body/51578/3 "2020-10-16T20:28:25Z")

</div>

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.

[https://auth0.com/docs/users/bulk-user-imports](https://auth0.com/docs/users/bulk-user-imports)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 3, 2020, 7:23pm UTC](https://community.auth0.com/t/bad-request-400-invalid-multipart-payload-format-invalid-body/51578/4 "2020-11-03T19:23:04Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
