Skip to main content
Best answer

What is the "z" variable?

  • January 17, 2023
  • 2 replies
  • 653 views

Forum|alt.badge.img+1

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.

Best answer by shalgrim

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!

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

shalgrim
Forum|alt.badge.img+8
  • Zapier Staff
  • 406 replies
  • Answer
  • January 17, 2023

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!


Forum|alt.badge.img+1
  • Author
  • Beginner
  • 14 replies
  • January 18, 2023

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?