Share feedback, ideas and get community help

Home
Members
stykujason
s
stykujason
Offline, last seen 2 months ago
Joined October 28, 2024
Trying to save a value returned from an http request to a variable. Sample request response:

{
"statusCode": 200,
"data": {
"vid": 12345677890,
"canonical-vid": 234567,
"portal-id": 123456,
"is-contact": true,
"properties": {
"owner_zoom_meeting_id": {
"value": "12345"}
}

I can save data.vid to a variable, and data.properties.owner_zoom_meeting_id.value to a variable. However, I can't save data.canonical-vid, or data.['canonical-vid']. The value doesn't get written. Is there a way to format the data section of the Save in variables to handle the hyphenated name?
5 comments
d
s
B
Can someone please give an example of how to do this with the result of an http request?

"If you really need to save a complex content into a variable, for example an object, you can use the JSON.stringify function to convert it into a text. And whenever you are using the variable, you can dynamically parse it back into an object using JSON.parse in an inline format:"

For example, I'm calling a GET from an API, which returns a JSON block of data. I would like to store all of it in a variable, so I can work with it - probably through a script block - and pull out the data I want. I'm not sure how to store the data in the variable correctly. When I try to save some portion of the data to a variable, and then return the variable, it comes back as undefined.
1 comment
B
I am using a Set variable block with value: Custom. I have this javascript in it (Execute on client? = true):

function getCookie(name) {
const value = ; ${document.cookie};
const parts = value.split(; ${name}=);
if (parts.length === 2) return parts.pop().split(';').shift();
}
const myCookieValue = getCookie("hubspotutk");
return myCookieValue

The variable gets set, I can retrieve the value and print it as a text bubble in the chat.

However, for some reason when I try to return the variable using a Zapier block, the variable isn't included in the return. The variable just isn't there.

Any variables I set through an Input Text block using "Save the answer in a variable" DO show up in Zapier. But these that I'm setting through the Set variable block with JS are not.

Any idea what I'm doing wrong?
1 comment
B