I just want to POST user details in pardot after the user registration

hello everyone,

I just want to POST user details in pardot after the user registration. to accomplish this requirement I have created a post-registration hook.

module.exports = function(user, context, cb) {
// Perform any asynchronous actions, e.g. send notification to Slack.
request({
method: ‘POST’,
url: ‘https:/demo/api’,
headers: {
‘Content-Type’: ‘application/json’,
},
body: { "email": "demo@email.com", "last_name": "last name", "first_name": "First name", "company":"Company" }
}, function(error, response, body) {
console.log(user)
console.log(context)
cb(error, response)
});
};

Not sure what’s wrong with this, is it related to functionality or data binding?

Error Response

{
“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.exports (/data/io/50601455-8df8-48c5-8fc7-93a43bf9660d/webtask.js:3:1)\n at /data/sandbox/node_modules/auth0-ext-compilers/lib/compilers/user-registration.js:30:16\n at Object.is_authorized (/data/sandbox/node_modules/auth0-ext-compilers/lib/authorization.js:13:81)\n at userRegistrationHandler (/data/sandbox/node_modules/auth0-ext-compilers/lib/compilers/user-registration.js:9:18)\n at /data/sandbox/node_modules/auth0-ext-compilers/lib/adapter.js:90:20\n at finish (/data/sandbox/node_modules/auth0-ext-compilers/node_modules/wreck/lib/index.js:369:16)\n at wrapped (/data/sandbox/node_modules/auth0-ext-compilers/node_modules/wreck/node_modules/hoek/lib/index.js:879:20)\n at onReaderFinish (/data/sandbox/node_modules/auth0-ext-compilers/node_modules/wreck/lib/index.js:415:16)\n at g (events.js:260:16)\n at emitNone (events.js:72:20)”
}

Please Help me :frowning:

hope you’ve already solved your problem.
However, to make things clear - the exception says that you’ve referenced object that is node.js is not aware of.
Basically, what you need is to import corresponding module to your hook.
Add the following line

    var request = require('request');

good luck!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.