Skip to main content
Best answer

Error message: Cannot convert undefined or null value to object (throttled)


jacob_nolley
Forum|alt.badge.img

I am trying to create a post request that returns an array of gross pay items. I thought I did it correctly and it said that my request was successful, but seconds later I got this big red alert that said “Cannot convert undefined or null value to object (throttled).”

I have attached the return code I am using and the model of the data it should be returning. I also attached a photo of the error message. Does anyone have any idea what is going on here?

Here is the Model of the data that should be returned. I am trying to pull in only the grossPayItems Array.
Here is the code I am using to pull in the grossPayItems. I have tried wrapping it in an array and not wrapping it in an array with the same results both times.
Here is the error message it is giving.

 

Best answer by DanversBest answer by Danvers

Hi @jacob_nolley - were you able to get to the bottom of this one? If not please let me know and I can ask the Support Team to take a look for you. 

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.

11 replies

ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • March 13, 2020

@jacob_nolley - Try to `z.console.log(results)`. Is it an object or a null/empty response? You probably need to check if the response is an object before returning it. Otherwise just return an empty array if it’s a search action, or an empty object if it’s a create action.


jacob_nolley
Forum|alt.badge.img
  • Author
  • Tinkerer
  • 12 replies
  • March 13, 2020

Do you mean like this? I tried this and I got the same result. It is a Search action. Is there a way to specify that an empty array is okay?

 


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • March 13, 2020

@jacob_nolley - Here’s what I meant:

const results = z.JSON.parse(response.content);

z.console.log(results); // <--- Here

return results;

To answer your question, you should actually check if the result is an array, like this:

const results = z.JSON.parse(response.content);
if (Array.isArray(results)) {
 return results;
} else {
 return [];
}

 


jacob_nolley
Forum|alt.badge.img
  • Author
  • Tinkerer
  • 12 replies
  • March 13, 2020

@ikbelkirasan

I did what you said and it said that that my results were not an array.

 

When my code looked like this, it said that my results were not an array:

const results = z.JSON.parse(response.content);

z.console.log(results.grossPayItems);

return results.grossPayItems;  

});

 

When my code looked like this, it gave me the red error code:

const results = z.JSON.parse(response.content);

z.console.log([results.grossPayItems]);

return [results.grossPayItems];  

});

 

When my code looked like this, it gave me the results pictured below. I am trying to get all of the results from the subObject “grossPayItems”:

const results = z.JSON.parse(response.content);

z.console.log(results);

return results;  

});

 


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • March 13, 2020

@jacob_nolley  - I suspect the API is returning an object, not an array. So, try the snippet below:

const results = z.JSON.parse(response.content);

const grossPayItems = results.grossPayItems;
if (Array.isArray(grossPayItems)) {
 return grossPayItems;
} else {
 return [];
}

jacob_nolley
Forum|alt.badge.img
  • Author
  • Tinkerer
  • 12 replies
  • March 13, 2020

@ikbelkirasan 

I received [ ] as a response. Do you know how I could fix this?

 

 


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • March 13, 2020

@jacob_nolley  - Can you post any console logs you got when you used `z.console.log` as I mentioned earlier? It’s important to see what the API response looks like exactly.


jacob_nolley
Forum|alt.badge.img
  • Author
  • Tinkerer
  • 12 replies
  • March 13, 2020

@ikbelkirasan 

When I do the z.console.log, it says “no logs to show”


Danvers
Forum|alt.badge.img+12
  • Zapier Staff
  • 3731 replies
  • Answer
  • March 26, 2020

Hi @jacob_nolley - were you able to get to the bottom of this one? If not please let me know and I can ask the Support Team to take a look for you. 


jacob_nolley
Forum|alt.badge.img
  • Author
  • Tinkerer
  • 12 replies
  • March 26, 2020

Heyy @Danvers,

 

I fortunately I didnt. Instead, I just implemented a work around and have been able to get that to work!

 

Thank you,

Jacob


Danvers
Forum|alt.badge.img+12
  • Zapier Staff
  • 3731 replies
  • April 6, 2020

Thanks for letting us know, I’m glad that you were able to find a workaround 🙌