User Import Bulk fail Bad Request

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_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",
“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

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? Please keep us updated on how it goes. Thank you!

1 Like

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.

Hi @bechirlahmer2 ,

Thank you for the updates.

For the filename=“users_import.json”, have you tried the absolute file path?


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

Thank you for the updates.

I searched on Google and found an article regarding Unable to open a file from PHP using fopen.

Hope it will help!

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…

i used exec and exec_shell with PHP to execute the CURL directly :slight_smile:

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