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

My APIs suddenly stopped working. What does unexpected token mean?

All my APIs on the dev server suddenly stopped working even though I haven't changed them. I get an unexpected token error. Why? What does that mean?
1514506515
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
It means that somewhere in one (or more) of those scripts there is a typo. Token is just the programming word for a character. Can you post the exact error?
How can there be a typo when I haven't changed anything.... SyntaxError: Unexpected token | It can't be a script though, I have disabled every single script, rotating the one thats being maintained to avoid that "Can't load scripts: error. And it happens with ALL of them. Could it be related to the fact my dev server campaign no longer has a functioning grid?
I think I figured it out. My Dev Server campaign is no longer communicating with the production server. And without communication with the production server the dev server can't read the API scripts.
1514526239

Edited 1514526357
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
That's not how the campaigns access the scripts as far as I know. I don't believe the DEV server has any connection to the production server at all; that's the point of the dev server actually - it runs off of a completely different build to test new features without causing problems on the production server. How did you identify that it wasn't communicating? Are your scripts all custom or do you use one-click scripts? If you have custom scripts (or want to import the code for the one-click scripts), I'd throw them into the google closure compiler to get a better idea of where the erroneous token is.
1514527363

Edited 1514527543
Because I always have to be logged into the production server in order to use my art library, so its obviously not disconnected. And right now the dev server can't connect to the production server from any of its links, like if you try  to the forum from the dev server you'll end up at the old beta test server. And the dev server isn't uploading any avatar images which are stored on the production server. Since this is all happening at the same time the APis stopped working, its reasonable to conclude that all the problems are connected.
1514527603

Edited 1514527658
I do know, 100% without a shadow of a doubt though, that its not a problem with any of the actual api scripts. Because I copy pasted each one of the customs and loaded up the one clicks I have to a different server in production and they all work fine.
Also none of the scripts work in other dev campaigns, though those I get an "error downloading scripts(probably no scripts exist for campaign) error even though I have a mix of custom and one click installed.
1514530005
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, well, guess we'll see what happens when they get all that fixed.
1514634430

Edited 1514635293
Chris D.
Pro
Sheet Author
API Scripter
Compendium Curator
I have the exact same problem.   My campaign on the DEV server is showing this on the API scripts page.  Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: SyntaxError: Unexpected token | I don't think the problem is my scripts.  I think that something broke on the DEV server.  I have not been on the DEV server for over a week. As I recall, I think everything was working more or less OK when last I was in it.  Today I made a few changes to the roll templates section of my custom character sheet, and tried it out. I saw the above error message. I tested the code through closure compiler, and there were no errors or warnings.  I rolled my changes back, and the error message still appeared. I then started deleting whole scripts.  Even after I deleted every script, and the html of the character sheet, and the css, so it was a totally codeless campaign, the error message was still saying I had an unexpected token | somewhere. But without any scripts or custom html, I had no tokens anywhere.  I then went to my test campaign (on the DEV server), which I occasionally use to test small code fragments. It was showing the same error. with the code that happened to be loaded upon it (different code). I then went to my real campaign on the production server. It was working fine.  I then loaded my new code onto the production server, and it works fine there. So both my campaigns on the dev server always give the same error, no matter what scripts or character sheet is loaded, or even with no scripts or character sheets loaded.  The same code on the production server seems to work fine.  For a while I was willing to believe that the new code on the DEV server is more picky, and was picking up an existing error in my code that the production server was not having any problem with, but like I said, I still get the error message even after deleting everything deleteable!
i ha this happen on prod server as it turned out one of the APi was missing a character or two in the coding. i had to disable the api one by one until the sandbox loaded then fixed the broken api then renabled it after saving it works fine now. 
1514656010
Chris D.
Pro
Sheet Author
API Scripter
Compendium Curator
Yes, I would have expected something like that to fix my campaign, but like I said, the problem persists even when everything has been deleted or disabled. 
1514656388
The Aaron
Pro
API Scripter
Here are some Javascript Bookmarklets that will help with that: Disable All Scripts: javascript:$('button.active.togglescript').click(); Enable All Scripts: javascript:$('button.inactive.togglescript').click(); You can also take all the scripts and copy them as a single unit with this: javascript:$('&lt;textarea&gt;&lt;/textarea&gt;').attr({id: 'TheAaronAllScripts'}).css({width:'100%',height: '30em'}).text($('.script .editor').map(function(idx,e){return e.env.editor.getValue();}).toArray().join("\n/* ############################### */;\n\n")).appendTo('body'); Then take it and paste it in the Google Closure Compiler and it can probably tell you where the issue is, then you just have to scroll around that part of the scripts till you can figure out what script it is and go fix it in your scripts:&nbsp; <a href="https://closure-compiler.appspot.com/home" rel="nofollow">https://closure-compiler.appspot.com/home</a>
1514656451
The Aaron
Pro
API Scripter
Oh, it persists when you have no scripts at all???&nbsp; That sounds like bug on Roll20's side...