429 error When trying to load the widget dynamically | Community
Skip to main content

429 error When trying to load the widget dynamically

  • September 12, 2018
  • 2 replies
  • 0 views

When I'm loading the script in the head tag with the key like this (

<script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=feb0916c-XXXXX-XXXX-XXXX-XXXXXXX"> </script>

) everything works fine,

But when i'm trying to load the widget dynamically like the following:

var loadScript = function() {
var node = document.createElement('script');
node.src = 'https://static.zdassets.com/ekr/snippet.js?key=feb0916c-XXXXX-XXXX-XXXX-XXXXXXX';
node.type = 'text/javascript';
node.async = true;
node.charset = 'utf-8';
document.getElementsByTagName('head')[0].appendChild(node);
}
loadScript();

i get 429 error.
i need to load the widget dynamically because i use different key for different brands that we have.

 

any idea why?

 

i can provide screenshots of the network request if needed.

This topic has been closed for replies.

2 replies

  • September 18, 2018

Hi Moshe, 

This type of error usually means that the account may have hit their rate limit. Here is an article that discusses the best practices for avoiding rate limiting:

https://develop.zendesk.com/hc/en-us/articles/360001074328-Best-practices-for-avoiding-rate-limiting

However, to truly learn more, feel free to reach out to our Support team for more details. 


  • April 27, 2020

Hi moshe, 

A bit late here, but for anyone reading this.

The error you are getting there is actually due to the script not having the "id" attribute to "ze-snippet", so at some other point another code is not able to grab the key since it's not able to find the script tag.

 

adding:

node.id = "ze-snippet";


Should solve your problem.