# User Import Bulk fail Bad Request

**URL:** <https://community.auth0.com/t/user-import-bulk-fail-bad-request/84548>\
**Category:** Get Help\
**Tags:** bulk-user-import, import, 400, api, error\
**Created:** [June 3, 2022, 9:21am UTC](https://community.auth0.com/t/user-import-bulk-fail-bad-request/84548 "2022-06-03T09:21:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bechirlahmer2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bechirlahmer2/32/37801_2.png) [@bechirlahmer2](https://community.auth0.com/u/bechirlahmer2)\
**Post date:** [June 3, 2022, 9:21am UTC](https://community.auth0.com/t/user-import-bulk-fail-bad-request/84548/1 "2022-06-03T09:21:36Z")

</div>

Hello  
i am using Auth0’s API to import users data from JSON file to to auth0, but i always got the same error message:  
{“statusCode”:400," error":“Bad Request”, “message”:“Users file must not be empty.”, “errorCode”:“operation\_not\_supported”}

$curl = curl\_init();  
curl\_setopt\_array($curl, [  
CURLOPT\_URL =\> “https://my\_domain/api/v2/jobs/users-imports”,  
CURLOPT\_RETURNTRANSFER =\> true,  
CURLOPT\_ENCODING =\> “”,  
CURLOPT\_MAXREDIRS =\> 10,  
CURLOPT\_TIMEOUT =\> 30,  
CURLOPT\_HTTP\_VERSION =\> CURL\_HTTP\_VERSION\_1\_1,  
CURLOPT\_CUSTOMREQUEST =\> “POST”,  
CURLOPT\_POSTFIELDS =\> “-----011000010111000001101001\r\nContent-Disposition: form-data; **name="users"; filename="users\_import.json**"\r\nContent-Type: text/json\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="connection\_id"\r\n\r\nMy\_cnx\_id\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="external\_id"\r\n\r\nMy\_external\_id\r\n-----011000010111000001101001–\r\n”,  
CURLOPT\_HTTPHEADER =\> [  
“authorization: Bearer “.$token.””,  
“content-type: multipart/form-data; boundary=—011000010111000001101001”  
],  
]);

i am using PHP, i tried to get the file with “fopen” and then get all data from the file with streams\_get\_contents, but i always get the same error message.

Thank you in advance

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [June 3, 2022, 5:05pm UTC](https://community.auth0.com/t/user-import-bulk-fail-bad-request/84548/4 "2022-06-03T17:05:48Z")

</div>

Hi @bechirlahmer2 ,

Welcome to the Auth0 Community!

The error of “Users file must not be empty” could be related to the import file does not have the correct format or content.

Could you please try importing a user file with one record in the [Management API](https://auth0.com/docs/api/management/v2#!/Jobs/post_users_imports)? Please keep us updated on how it goes. Thank you!

---

<div class="post-metadata">

**Author:** ![bechirlahmer2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bechirlahmer2/32/37801_2.png) [@bechirlahmer2](https://community.auth0.com/u/bechirlahmer2)\
**Post date:** [June 4, 2022, 7:56am UTC](https://community.auth0.com/t/user-import-bulk-fail-bad-request/84548/5 "2022-06-04T07:56:34Z")

</div>

Thank you for your replay,  
i checked the format of the file with the extension import/export and it works, i also tried the Managment API and it works. i got that error only when i try to import users using the endpoint.

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [June 6, 2022, 6:01pm UTC](https://community.auth0.com/t/user-import-bulk-fail-bad-request/84548/6 "2022-06-06T18:01:44Z")

</div>

Hi @bechirlahmer2 ,

Thank you for the updates.

For the **filename=“users\_import.json”** , have you tried the absolute file path?

---

<div class="post-metadata">

**Author:** ![bechirlahmer2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bechirlahmer2/32/37801_2.png) [@bechirlahmer2](https://community.auth0.com/u/bechirlahmer2)\
**Post date:** [June 7, 2022, 8:16am UTC](https://community.auth0.com/t/user-import-bulk-fail-bad-request/84548/7 "2022-06-07T08:16:51Z")

</div>

Hello

Yes, i tried with absolute path, i tried to upload file with POST form-data curl and i always got the same error

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [June 7, 2022, 4:17pm UTC](https://community.auth0.com/t/user-import-bulk-fail-bad-request/84548/8 "2022-06-07T16:17:51Z")

</div>

Thank you for the updates.

I searched on Google and found an article regarding [Unable to open a file from PHP using fopen](https://stackoverflow.com/questions/37065844/unable-to-open-a-file-from-php-using-fopen).

Hope it will help!

---

<div class="post-metadata">

**Author:** ![bechirlahmer2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bechirlahmer2/32/37801_2.png) [@bechirlahmer2](https://community.auth0.com/u/bechirlahmer2)\
**Post date:** [June 8, 2022, 8:04am UTC](https://community.auth0.com/t/user-import-bulk-fail-bad-request/84548/9 "2022-06-08T08:04:52Z")

</div>

i already opened the file and read the content, i tried to run the import directly with Curl and it works fine. but with PHP, even i could open the file, read all content, get full path … i always get the same error.  
this is my POSTFIELD:  
`-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"users\"; filename=\"$file\"\r\nContent-Type: text/json\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"connection_id\"\r\n\r\n **********\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"external_id\"\r\n\r\n****** \r\n-----011000010111000001101001--\r\n`

on **$file** variable, i put the path, full path, content get stream, fopen, content…

---

<div class="post-metadata">

**Author:** ![bechirlahmer2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bechirlahmer2/32/37801_2.png) [@bechirlahmer2](https://community.auth0.com/u/bechirlahmer2)\
**Post date:** [June 9, 2022, 9:27am UTC](https://community.auth0.com/t/user-import-bulk-fail-bad-request/84548/10 "2022-06-09T09:27:44Z")

</div>

i used exec and exec\_shell with PHP to execute the CURL directly 🙂

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [June 9, 2022, 6:06pm UTC](https://community.auth0.com/t/user-import-bulk-fail-bad-request/84548/11 "2022-06-09T18:06:15Z")

</div>

Thank you for the updates! Glad to know that you have resolve it 👏

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 21, 2022, 3:38pm UTC](https://community.auth0.com/t/user-import-bulk-fail-bad-request/84548/12 "2022-12-21T15:38:26Z")

</div>


