I’m using the following function to send a password reset email:
function passwordReset(userId, email) {
var options = {
method: 'POST',
url: 'https://.../api/v2/tickets/password-change',
headers: { authorization: 'Bearer ' + token },
body: {
result_url: '...',
user_id: userId,
new_password: 'secret',
connection_id: '...',
email: email,
ttl_sec: 0
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
}
I’m pretty sure that:
- The token is correct. I’m using the same one for tickets/email-verification endpoint and it works ok,
- The userId is copied from your dashboard and it works with tickets/email-verification endpoint
- I have correctly setupped a client (granted proper permissions) and connection. I got the connection id from the /connections endpoint.
- The email is also correct
Using the same token and user id I am able to use tickets/email-verification and connections endpoints.
However with tickets/password-change I’m getting the following
{ statusCode: 400,
error: 'Bad Request',
message: 'Payload validation error: \'Invalid property user_id\'.',
errorCode: 'invalid_body' }
Hi @krasimir
I tried to test the issue using postman, and yes I am also facing it.
But as per my understanding, the error says that there is some problem with the body params and not the token.
It states that the service doesn’t recognize user_id as a body param.
When I tried the same request without the user_id field, I received the ticket positively.
Thus, let us wait for some experts @jmangelo to comment about this or you can continue using it excluding the user_id field.
Thanks!
Yep, when I remove the user_id from the request it works and that satisfies our use case. So all good for now. Thanks.
Got the same issue trying to add app_metadata for a user from my backend. The following didn’t work:
var jsonStr = fmt.Sprintf("{\"app_metadata\": { \"user_id\": \"%s\" }}", userId)
req, err := http.NewRequest(http.MethodPatch, urlStr, strings.NewReader(jsonStr))
I also received such a response:
{ statusCode: 400,
error: 'Bad Request',
message: 'Payload validation error: \'Invalid property user_id\'.',
errorCode: 'invalid_body' }
I think the issue is app_metadata can’t have properties with “_” in the name. I removed the “user_” and it worked.
var jsonStr = fmt.Sprintf("{\"app_metadata\": { \"id\": \"%s\" }}", userId)
req, err := http.NewRequest(http.MethodPatch, urlStr, strings.NewReader(jsonStr))
Hope this helps someone. I spent a lot of time debugging this.