Skip to main content

What is the z variable that is injected into many of the CLI-applications’ methods?  For example: https://github.com/zapier/zapier-platform-example-app-session-auth/blob/16ec7a76bcd51f9a6100cde74a31e3ca2a83c58b/authentication.js#L19.

Is there any documentation? 

In particular, I’d like to know if the z.request method supports POSTing a SSL certificate and key.

Hey Benjamin,

We document the z object here. You can definitely send POST requests, but I don’t know for sure about the SSL cert and key. You might need to play around to find out.

Let us know if you have any more questions!


Thanks for the response and the reference.

I don’t see any request options that would allow me to provide these files.

I’m trying to do this (node):

const https = require('https')
const querystring = require('querystring')

const options = {
cert: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n",
key: "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n",
host: 'accounts.adp.com',
path: '/auth/oauth/v2/token',
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}

const requestData = {
grant_type: 'client_credentials',
client_id: 'REDACTED',
client_secret: 'REDACTED',
}

const requestBody = querystring.stringify(requestData);

const req = https.request(options, (res) => {
let response = ''

console.log('Status Code:', res.statusCode);

res.on('data', (chunk) => {
response += chunk
})
res.on('end', ()=>{
console.log('Body: ', JSON.parse(response));
})
}).on("error", (err) => {
console.error("Error: ", err.message);
});

req.write(requestBody)
req.end()

Can this be done with your z object natively?