Post User Registration: Trouble doing a POST request

I am trying to make a POST request to my REST Endpoint that I set up on my server. I have created an API Authorization in the Auth0 dashboard.

I am able to do a POST request successfully from the Advanced REST Client. However, when I try to do the request from the webhook – nothing works. None of my POST variables seem to be defined.

What is the correct way to make a POST request from the web hook? Is there any documentation that goes over this??

var request = require(‘request@2.56.0’);

request({
method: ‘POST’,
url: ‘my_rest_endpoint_url is here’,
headers: {
‘Content-Type’: ‘application/x-www-form-urlencoded’,
},
body: { "firstname": "${user.username}", "username": "${user.id}”}
}, function(error, response, body) {
console.log(user)
console.log(context)
cb(error, response)
});

My script doesn’t get the username OR the id. Nothing seems to work. When I test this from the runner on the webtask page – it returns a 500 error.

Can you do a console.log(JSON.stringify(user)); to see what user attributes are available in the script?

Console.log didn’t give me anything…

Can you please provide some more information for me to try and reproduce this.

  • Are you creating the user from the dashboard, or are they registering via Lock?
  • Does it happen for all users?

I was doing the console.log and trying to use the runner. The runner always seems to return errors… so I now use my mobile demo application. That seems to print things out.

The runner had a bug that should be resolved. If you copy the code from your Hook, delete your existing Hook, then create a new one with the pasted code, the issue should resolve.

Summary from the discussion in the comments:

The hook runner had a bug that caused an error to always be returned. This should now be fixed, but if a similar situation occurs you may want to trigger the hook normally instead of using the runner.