Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

API crashes with the error "Unexpected token ILLEGAL"

Right I don't understand what causes that error in particular?
1439966045

Edited 1439966420
Pat S.
Forum Champion
Sheet Author
Let's start off with the basics. Can you please follow Steps 1-3 of our Solving Technical Issues wiki page, taking special care to temporarily disable all browser add-ons and extensions, temporarily pause your anti-virus, and try switching browsers (for Chrome/Firefox specific issues) to see if one of those components is causing the problem. If all of that fails, please follow Step 4 , including providing all of the necessary information, so that we can further assist you. Also what do you have loaded in your api?
1439989470
The Aaron
Roll20 Production Team
API Scripter
Also, what API Scripts are you running.   When does this error occur?  ( Is it there when you save a script , or does it happen in response to a command, or when you log into the Game?) In the case of the error message "Unexpected token ILLEGAL":  This is a Javascript error that occurs when the script is being parsed (I'm guessing you get this in the bolded case above).  The Javascript parser breaks up everything in the script into small units it understands (things like "if", "{", "var", "42", etc).  It calls each of these units a token (the process is called tokenization).  There are 4 types of tokens it understands (Identifier names like "if", Punctuators like ";", numerical literals like "42", string literals like "'bob'").  Anything else is considered an ILLEGAL token. In your case, this is probably one of 2 things (first one most likely): 1) In copying and pasting the script code into the API editor, you've accidentally introduced a Unicode character that it doesn't know how to parse.  This is really hard to diagnose because the character could be completely invisible (a zero width space, a hard space, etc), or could look like a regular character (a fancy " instead of the standard ASCII one).  The best thing to do in this case is copy the script again from the source (preferably a GIST or GitHub page). 2) There might be something in the scripts before and after that are causing an issue.  Because Javascript has a rule for automatic semicolon insertion, things like: log('bob') will get turned into the correct: log('bob'); when javascript parses them. There are various reasons to always put in your ; despite this ability (like the fact that it does it wrong in some cases), but in the case of the API, it is especially important at the ends of scripts.  The API concatenates all the scripts together into a single script, then passes those to the API server to execute.  When that concatenation occurs, if there is no final carriage return at the end of a script, you can get two lines joined together: log('bob')var tim = tim || (function(){ Without the ; on the last line of the first script, you get problems.