I’m trying to call a POST REST API from the post user registration web hook and I keep getting a 500 error. I know that my REST API works so I’m not sure why it’s getting a 500 error.
“code”: 500,
“error”: “Script generated an unhandled asynchronous exception.”,
“details”: “ReferenceError: request is not defined”,
“name”: “ReferenceError”,
“message”: “request is not defined”,
“stack”: "ReferenceError: request is not defined\n at module.export
I’m still having trouble with this. Do you have an example of a POST? I set up the authorization API and everything seems to work when I make a Request from Advanced Rest Client but it doesn’t seem to work at all from the webhook. I’ve tried finding information on Google but haven’t found anything that explains that library.
@prashant I’m now trying to figure out how to send extra HTTP headers with the request. I’m not having any luck at that. Do you know how to add an HTTP header with the POST? I tried doing the options but the console returned request.options isn’t a function.
Do you know if you can tell where the request is coming from in a hook? I have a dev environment and a production one - I want to change the API thats being called based on the environment …
@harry this depends on how you have separated your dev/prod environments. If you are using different clients, the context object in the Hook has the clientID property which you can check, e.g:
var url;
if(context.clientID === 'MY_DEV_CLIENT_ID'){
url = 'https://dev.myapp.com';
} else if (context.clientID === 'MY_PROD_CLIENT_ID'){
url = 'https://myapp.com';
}