Overview
When attempting to import users using the Management API endpoint /api/v2/jobs/users-imports with the upsert
option, the following error message is encountered:
Failed to parse users’ file JSON when importing users. Make sure it is valid JSON.
This issue does not occur using the Extension User Import/Export feature.
Cause
Extension User Import/Export:
- The Extension User Import/Export feature automatically converts JSON files from UTF-16 to UTF-8, which is why the error is not encountered when using this method.
Management API:
- The Management API does not perform this conversion, so it is necessary to manually ensure the JSON file is in UTF-8 encoding.
Solution
To resolve this issue, follow these steps:
-
Identify the Encoding Issue
The error occurs because the JSON file being imported contains a Byte Order Mark (BOM) for UTF-16 encoding. The Management API
/api/v2/jobs/users-imports
expects the file to be in UTF-8 encoding without a BOM. -
Convert the File Encoding
To fix the encoding issue, the JSON file must be converted from UTF-16 to UTF-8.
-
Re-attempt the Import
Now that the file has been converted to the correct encoding, re-attempt the user import using the Management API endpoint
/api/v2/jobs/users-imports
:- Make a POST request to
/api/v2/jobs/users-imports
with the updated JSON file and theupsert
option.
- Make a POST request to