Error when Calling Management Endpoint in Get User Script


Running the Management API GET users-by-email endpoint with axios in the Get Users script throws the error: “Error fetching user from API: unexpected end of file”. A possible cause for this is using a non-URI formatted email in the request.


For example, the following code can return a 400 error which indicates failure due to invalid syntax such as using a non-URI formatted email.

const userResponse = await axios.get(`${userEmail}`, {
    headers: {
    'Accept': 'application/json',
    'Accept-Encoding': 'gzip,deflate,compress',
    'Authorization': `Bearer ${managementAPI}`


To make sure userEmail is in the right format:

  1. Add the following to convert into URI formatted email:

    const userEmail = encodeURIComponent(email);

  2. Or, Add 'Accept-Encoding': 'gzip,deflate,compress' to the header.