Trouble trying to get users by email

Hi everyone, I’m having trouble trying to make a request to the user-by-email api, i’m doing a GET, passing the Bearer code in the header as Authorization, and passing the email that i want to search in the url like that

fetch(‘https://dev-m2o8uvo7.us.auth0.com/api/v2/users-by-email?email=pedro.s.morais@gmail.com’, {
method: ‘GET’,
headers: new Headers({
‘Accept’: “application/json”,
‘Content-Type’: ‘application/json; charset=utf-8’,
‘Authorization’: ‘Bearer token…’
}),
})
.then(function(response) {
console.log(response)
})
.catch(err => {
console.log(err)
})

I’m ussing the token generated in the Dashboard > Applications > API’s > API Explorer

I tried various ways, like removing the ‘’ but it didn’t work and always return 400,

body: (…)
bodyUsed: false
headers: Headers {}
ok: false
redirected: false
status: 400
statusText: “”
type: “basic”
url: "https://dev-m2o8uvo7.us.auth0.com/api/v2/users-by-email?e

I’ve even tried following this doc that use axios

and even that didn’t work.

I tested the resquest in postman and in the Auth0 api managment, and in both works fine and i can see the data

I don’t know what i’m doing wrong

Thanks

Hi @meta3102,

Welcome to the Auth0 Community!

I understand you are having trouble forming your GET /api/v2/users-by-email request.

Could you try running the request on Postman? And then copying and pasting that Postman code snippet with Node.js and its appropriate framework and see if you can get this to work?

The code snippet should provide clarity on how to form the request.

Please let me know if you’re able to resolve this issue.

Hello @rueben.tiow , thanks for the response.

So, i tried with the code that postman generate (based on the link that you passed), and still doesn’t work, (I tried with fetch and XHR)

I ran the code in postman, and then copy and paste in my code, and is returning 400, when in postman returns the data of the user.

  • UPDATE
    I tried with others endpoints, like the send verification emails and is returning 400 too, i don’t know what i’m doing wrong if I copy and paste the values that works in postman

Hi @meta3102,

My apologies for the delayed response.

To assist you further, could you please clarify what is the error message when you get the HTTP 400 status code?

And, could you please check if you missed any parameters in the request?

Generally, the HTTP 400 status code indicates a BAD REQUEST. Without more clarity of the parameters you used in your request, it is hard to determine the root cause of the error.

Because of this, could you please share with me the complete request in your app via DM?

Since making the GET request calls on Postman and the Management API v2 are correct, I believe the issue may be related to the request in your app.

Thank you.