Script issues: Unterminated String Constant and Expect } when changing parameter

I have a script that is working intermittently. When I load the POST into Insomnia it works every time. This script was working for me earlier, but now I’m having issues. I’ve looked over the script multiple times and can’t see anything.

It only works with one character in the parameter. Its very odd that adding additional characters produces different errors.

Any ideas?

Try isolating that script by itself and then run it. I’m curious.

Definitely tried that last night and again this morning. I have secluded the error to JSON.parse(). It fails intermittently as shown in the gif videos (works with “F”. fails on “Fr”. fails on “Fre”, works with on “French c”, Fails with “French”). Additionally, I’ve validated the JSON data and I don’t see any errors with all of these returns.

I’m about ready to take my frustration out on my monitor…

JSON Data from “Fre”

{
  "drinks": [
    {
      "idDrink": "17197",
      "strDrink": "French 75",
      "strDrinkAlternate": null,
      "strDrinkES": null,
      "strDrinkDE": null,
      "strDrinkFR": null,
      "strDrinkZH-HANS": null,
      "strDrinkZH-HANT": null,
      "strTags": "IBA,ContemporaryClassic",
      "strVideo": null,
      "strCategory": "Ordinary Drink",
      "strIBA": "Contemporary Classics",
      "strAlcoholic": "Alcoholic",
      "strGlass": "Collins glass",
      "strInstructions": "Combine gin, sugar, and lemon juice in a cocktail shaker filled with ice. Shake vigorously and strain into a chilled champagne glass. Top up with Champagne. Stir gently.",
      "strInstructionsES": null,
      "strInstructionsDE": "Gin, Zucker und Zitronensaft in einem mit Eis gefüllten Cocktailshaker mischen. Kräftig schütteln und in ein gekühltes Champagnerglas abseihen. Mit Champagner auffüllen. Vorsichtig umrühren.",
      "strInstructionsFR": null,
      "strInstructionsZH-HANS": null,
      "strInstructionsZH-HANT": null,
      "strDrinkThumb": "https:\/\/www.thecocktaildb.com\/images\/media\/drink\/hrxfbl1606773109.jpg",
      "strIngredient1": "Gin",
      "strIngredient2": "Sugar",
      "strIngredient3": "Lemon juice",
      "strIngredient4": "Champagne",
      "strIngredient5": "Orange",
      "strIngredient6": "Maraschino cherry",
      "strIngredient7": null,
      "strIngredient8": null,
      "strIngredient9": null,
      "strIngredient10": null,
      "strIngredient11": null,
      "strIngredient12": null,
      "strIngredient13": null,
      "strIngredient14": null,
      "strIngredient15": null,
      "strMeasure1": "1 1\/2 oz ",
      "strMeasure2": "2 tsp superfine ",
      "strMeasure3": "1 1\/2 oz ",
      "strMeasure4": "4 oz Chilled ",
      "strMeasure5": "1 ",
      "strMeasure6": "1 ",
      "strMeasure7": null,
      "strMeasure8": null,
      "strMeasure9": null,
      "strMeasure10": null,
      "strMeasure11": null,
      "strMeasure12": null,
      "strMeasure13": null,
      "strMeasure14": null,
      "strMeasure15": null,
      "strImageSource": "https:\/\/pixabay.com\/de\/photos\/champagner-cocktail-french-75-5374793\/",
      "strImageAttribution": "robert84ak https:\/\/pixabay.com\/de\/users\/robert84ak-16722616\/",
      "strCreativeCommonsConfirmed": "Yes",
      "dateModified": "2017-09-02 17:10:15"
    },
    {
      "idDrink": "17213",
      "strDrink": "French Martini",
      "strDrinkAlternate": null,
      "strDrinkES": null,
      "strDrinkDE": null,
      "strDrinkFR": null,
      "strDrinkZH-HANS": null,
      "strDrinkZH-HANT": null,
      "strTags": "NewEra,IBA",
      "strVideo": null,
      "strCategory": "Cocktail",
      "strIBA": "New Era Drinks",
      "strAlcoholic": "Alcoholic",
      "strGlass": "Cocktail glass",
      "strInstructions": "Pour all ingredients into shaker with ice cubes. Shake well and strain into a chilled cocktail glass. Squeeze oil from lemon peel onto the drink.",
      "strInstructionsES": null,
      "strInstructionsDE": "Alle Zutaten in den Shaker mit Eiswürfeln geben. Gut schütteln und in ein gekühltes Cocktailglas abseihen. Das Öl aus der Zitronenschale auf das Getränk drücken.",
      "strInstructionsFR": null,
      "strInstructionsZH-HANS": null,
      "strInstructionsZH-HANT": null,
      "strDrinkThumb": "https:\/\/www.thecocktaildb.com\/images\/media\/drink\/clth721504373134.jpg",
      "strIngredient1": "Vodka",
      "strIngredient2": "Raspberry Liqueur",
      "strIngredient3": "pineapple juice",
      "strIngredient4": null,
      "strIngredient5": null,
      "strIngredient6": null,
      "strIngredient7": null,
      "strIngredient8": null,
      "strIngredient9": null,
      "strIngredient10": null,
      "strIngredient11": null,
      "strIngredient12": null,
      "strIngredient13": null,
      "strIngredient14": null,
      "strIngredient15": null,
      "strMeasure1": "4.5 cl",
      "strMeasure2": "1.5 cl",
      "strMeasure3": "1.5 cl",
      "strMeasure4": null,
      "strMeasure5": null,
      "strMeasure6": null,
      "strMeasure7": null,
      "strMeasure8": null,
      "strMeasure9": null,
      "strMeasure10": null,
      "strMeasure11": null,
      "strMeasure12": null,
      "strMeasure13": null,
      "strMeasure14": null,
      "strMeasure15": null,
      "strImageSource": null,
      "strImageAttribution": null,
      "strCreativeCommonsConfirmed": "No",
      "dateModified": "2017-09-02 18:25:34"
    },
    {
      "idDrink": "17248",
      "strDrink": "French Negroni",
      "strDrinkAlternate": null,
      "strDrinkES": null,
      "strDrinkDE": null,
      "strDrinkFR": null,
      "strDrinkZH-HANS": null,
      "strDrinkZH-HANT": null,
      "strTags": null,
      "strVideo": null,
      "strCategory": "Cocktail",
      "strIBA": null,
      "strAlcoholic": "Alcoholic",
      "strGlass": "Martini Glass",
      "strInstructions": "Add ice to a shaker and pour in all ingredients.\nUsing a bar spoon, stir 40 to 45 revolutions or until thoroughly chilled.\nStrain into a martini glass or over ice into a rocks glass. Garnish with orange twist.",
      "strInstructionsES": null,
      "strInstructionsDE": "Füge Eis in einen Shaker und gieße alle Zutaten ein. Rühren Sie mit einem Barlöffel 40 bis 45 Umdrehungen oder bis zur vollständigen Abkühlung. In ein Martini-Glas oder über Eis in ein Rocks Glas abseihen. Mit Orangenspirale garnieren.",
      "strInstructionsFR": null,
      "strInstructionsZH-HANS": null,
      "strInstructionsZH-HANT": null,
      "strDrinkThumb": "https:\/\/www.thecocktaildb.com\/images\/media\/drink\/x8lhp41513703167.jpg",
      "strIngredient1": "Gin",
      "strIngredient2": "Lillet",
      "strIngredient3": "Sweet Vermouth",
      "strIngredient4": "Orange Peel",
      "strIngredient5": null,
      "strIngredient6": null,
      "strIngredient7": null,
      "strIngredient8": null,
      "strIngredient9": null,
      "strIngredient10": null,
      "strIngredient11": null,
      "strIngredient12": null,
      "strIngredient13": null,
      "strIngredient14": null,
      "strIngredient15": null,
      "strMeasure1": "1 oz",
      "strMeasure2": "1 oz",
      "strMeasure3": "1 oz",
      "strMeasure4": "1",
      "strMeasure5": null,
      "strMeasure6": null,
      "strMeasure7": null,
      "strMeasure8": null,
      "strMeasure9": null,
      "strMeasure10": null,
      "strMeasure11": null,
      "strMeasure12": null,
      "strMeasure13": null,
      "strMeasure14": null,
      "strMeasure15": null,
      "strImageSource": null,
      "strImageAttribution": null,
      "strCreativeCommonsConfirmed": "No",
      "dateModified": "2017-12-19 17:06:07"
    },
    {
      "idDrink": "17198",
      "strDrink": "French Connection",
      "strDrinkAlternate": null,
      "strDrinkES": null,
      "strDrinkDE": null,
      "strDrinkFR": null,
      "strDrinkZH-HANS": null,
      "strDrinkZH-HANT": null,
      "strTags": "IBA,ContemporaryClassic",
      "strVideo": null,
      "strCategory": "Ordinary Drink",
      "strIBA": "Contemporary Classics",
      "strAlcoholic": "Alcoholic",
      "strGlass": "Old-fashioned glass",
      "strInstructions": "Pour all ingredients directly into old fashioned glass filled with ice cubes. Stir gently.",
      "strInstructionsES": null,
      "strInstructionsDE": "Alle Zutaten direkt in ein old fashioned Glas mit Eiswürfeln geben. Vorsichtig umrühren.",
      "strInstructionsFR": null,
      "strInstructionsZH-HANS": null,
      "strInstructionsZH-HANT": null,
      "strDrinkThumb": "https:\/\/www.thecocktaildb.com\/images\/media\/drink\/zaqa381504368758.jpg",
      "strIngredient1": "Cognac",
      "strIngredient2": "Amaretto",
      "strIngredient3": null,
      "strIngredient4": null,
      "strIngredient5": null,
      "strIngredient6": null,
      "strIngredient7": null,
      "strIngredient8": null,
      "strIngredient9": null,
      "strIngredient10": null,
      "strIngredient11": null,
      "strIngredient12": null,
      "strIngredient13": null,
      "strIngredient14": null,
      "strIngredient15": null,
      "strMeasure1": "1 1\/2 oz ",
      "strMeasure2": "3\/4 oz ",
      "strMeasure3": null,
      "strMeasure4": null,
      "strMeasure5": null,
      "strMeasure6": null,
      "strMeasure7": null,
      "strMeasure8": null,
      "strMeasure9": null,
      "strMeasure10": null,
      "strMeasure11": null,
      "strMeasure12": null,
      "strMeasure13": null,
      "strMeasure14": null,
      "strMeasure15": null,
      "strImageSource": null,
      "strImageAttribution": null,
      "strCreativeCommonsConfirmed": "No",
      "dateModified": "2017-09-02 17:12:39"
    }
  ]
}

Hmm, I’d have my doubts its the function itself, will be using .net framework meaning used in many many softwares.
Also I use this function many times in my PMS intergration which has to have processed hundreds of thousands of requests between booking data sync, room posts and epos sales between 4 hotels…

Where were you copying the returned json from to validate?
Return the raw json within samba and ctl+c when return dialogue is up and paste to json formatter.
You just need to remove the
‐---------
OK
----------
Off the bottom from the buttkn

The return didn’t let me copy, so I use Insomnia (https://insomnia.rest/) for sending REST requests and getting the raw data.

Here is the raw response from “https://www.thecocktaildb.com/api/json/v1/1/search.php?s=french”:

{"drinks":[{"idDrink":"17197","strDrink":"French 75","strDrinkAlternate":null,"strDrinkES":null,"strDrinkDE":null,"strDrinkFR":null,"strDrinkZH-HANS":null,"strDrinkZH-HANT":null,"strTags":"IBA,ContemporaryClassic","strVideo":null,"strCategory":"Ordinary Drink","strIBA":"Contemporary Classics","strAlcoholic":"Alcoholic","strGlass":"Collins glass","strInstructions":"Combine gin, sugar, and lemon juice in a cocktail shaker filled with ice. Shake vigorously and strain into a chilled champagne glass. Top up with Champagne. Stir gently.","strInstructionsES":null,"strInstructionsDE":"Gin, Zucker und Zitronensaft in einem mit Eis gef\u00fcllten Cocktailshaker mischen. Kr\u00e4ftig sch\u00fctteln und in ein gek\u00fchltes Champagnerglas abseihen. Mit Champagner auff\u00fcllen. Vorsichtig umr\u00fchren.","strInstructionsFR":null,"strInstructionsZH-HANS":null,"strInstructionsZH-HANT":null,"strDrinkThumb":"https:\/\/www.thecocktaildb.com\/images\/media\/drink\/hrxfbl1606773109.jpg","strIngredient1":"Gin","strIngredient2":"Sugar","strIngredient3":"Lemon juice","strIngredient4":"Champagne","strIngredient5":"Orange","strIngredient6":"Maraschino cherry","strIngredient7":null,"strIngredient8":null,"strIngredient9":null,"strIngredient10":null,"strIngredient11":null,"strIngredient12":null,"strIngredient13":null,"strIngredient14":null,"strIngredient15":null,"strMeasure1":"1 1\/2 oz ","strMeasure2":"2 tsp superfine ","strMeasure3":"1 1\/2 oz ","strMeasure4":"4 oz Chilled ","strMeasure5":"1 ","strMeasure6":"1 ","strMeasure7":null,"strMeasure8":null,"strMeasure9":null,"strMeasure10":null,"strMeasure11":null,"strMeasure12":null,"strMeasure13":null,"strMeasure14":null,"strMeasure15":null,"strImageSource":"https:\/\/pixabay.com\/de\/photos\/champagner-cocktail-french-75-5374793\/","strImageAttribution":"robert84ak https:\/\/pixabay.com\/de\/users\/robert84ak-16722616\/","strCreativeCommonsConfirmed":"Yes","dateModified":"2017-09-02 17:10:15"},{"idDrink":"17213","strDrink":"French Martini","strDrinkAlternate":null,"strDrinkES":null,"strDrinkDE":null,"strDrinkFR":null,"strDrinkZH-HANS":null,"strDrinkZH-HANT":null,"strTags":"NewEra,IBA","strVideo":null,"strCategory":"Cocktail","strIBA":"New Era Drinks","strAlcoholic":"Alcoholic","strGlass":"Cocktail glass","strInstructions":"Pour all ingredients into shaker with ice cubes. Shake well and strain into a chilled cocktail glass. Squeeze oil from lemon peel onto the drink.","strInstructionsES":null,"strInstructionsDE":"Alle Zutaten in den Shaker mit Eisw\u00fcrfeln geben. Gut sch\u00fctteln und in ein gek\u00fchltes Cocktailglas abseihen. Das \u00d6l aus der Zitronenschale auf das Getr\u00e4nk dr\u00fccken.","strInstructionsFR":null,"strInstructionsZH-HANS":null,"strInstructionsZH-HANT":null,"strDrinkThumb":"https:\/\/www.thecocktaildb.com\/images\/media\/drink\/clth721504373134.jpg","strIngredient1":"Vodka","strIngredient2":"Raspberry Liqueur","strIngredient3":"pineapple juice","strIngredient4":null,"strIngredient5":null,"strIngredient6":null,"strIngredient7":null,"strIngredient8":null,"strIngredient9":null,"strIngredient10":null,"strIngredient11":null,"strIngredient12":null,"strIngredient13":null,"strIngredient14":null,"strIngredient15":null,"strMeasure1":"4.5 cl","strMeasure2":"1.5 cl","strMeasure3":"1.5 cl","strMeasure4":null,"strMeasure5":null,"strMeasure6":null,"strMeasure7":null,"strMeasure8":null,"strMeasure9":null,"strMeasure10":null,"strMeasure11":null,"strMeasure12":null,"strMeasure13":null,"strMeasure14":null,"strMeasure15":null,"strImageSource":null,"strImageAttribution":null,"strCreativeCommonsConfirmed":"No","dateModified":"2017-09-02 18:25:34"},{"idDrink":"17248","strDrink":"French Negroni","strDrinkAlternate":null,"strDrinkES":null,"strDrinkDE":null,"strDrinkFR":null,"strDrinkZH-HANS":null,"strDrinkZH-HANT":null,"strTags":null,"strVideo":null,"strCategory":"Cocktail","strIBA":null,"strAlcoholic":"Alcoholic","strGlass":"Martini Glass","strInstructions":"Add ice to a shaker and pour in all ingredients.\nUsing a bar spoon, stir 40 to 45 revolutions or until thoroughly chilled.\nStrain into a martini glass or over ice into a rocks glass. Garnish with orange twist.","strInstructionsES":null,"strInstructionsDE":"F\u00fcge Eis in einen Shaker und gie\u00dfe alle Zutaten ein. R\u00fchren Sie mit einem Barl\u00f6ffel 40 bis 45 Umdrehungen oder bis zur vollst\u00e4ndigen Abk\u00fchlung. In ein Martini-Glas oder \u00fcber Eis in ein Rocks Glas abseihen. Mit Orangenspirale garnieren.","strInstructionsFR":null,"strInstructionsZH-HANS":null,"strInstructionsZH-HANT":null,"strDrinkThumb":"https:\/\/www.thecocktaildb.com\/images\/media\/drink\/x8lhp41513703167.jpg","strIngredient1":"Gin","strIngredient2":"Lillet","strIngredient3":"Sweet Vermouth","strIngredient4":"Orange Peel","strIngredient5":null,"strIngredient6":null,"strIngredient7":null,"strIngredient8":null,"strIngredient9":null,"strIngredient10":null,"strIngredient11":null,"strIngredient12":null,"strIngredient13":null,"strIngredient14":null,"strIngredient15":null,"strMeasure1":"1 oz","strMeasure2":"1 oz","strMeasure3":"1 oz","strMeasure4":"1","strMeasure5":null,"strMeasure6":null,"strMeasure7":null,"strMeasure8":null,"strMeasure9":null,"strMeasure10":null,"strMeasure11":null,"strMeasure12":null,"strMeasure13":null,"strMeasure14":null,"strMeasure15":null,"strImageSource":null,"strImageAttribution":null,"strCreativeCommonsConfirmed":"No","dateModified":"2017-12-19 17:06:07"},{"idDrink":"17198","strDrink":"French Connection","strDrinkAlternate":null,"strDrinkES":null,"strDrinkDE":null,"strDrinkFR":null,"strDrinkZH-HANS":null,"strDrinkZH-HANT":null,"strTags":"IBA,ContemporaryClassic","strVideo":null,"strCategory":"Ordinary Drink","strIBA":"Contemporary Classics","strAlcoholic":"Alcoholic","strGlass":"Old-fashioned glass","strInstructions":"Pour all ingredients directly into old fashioned glass filled with ice cubes. Stir gently.","strInstructionsES":null,"strInstructionsDE":"Alle Zutaten direkt in ein old fashioned Glas mit Eisw\u00fcrfeln geben. Vorsichtig umr\u00fchren.","strInstructionsFR":null,"strInstructionsZH-HANS":null,"strInstructionsZH-HANT":null,"strDrinkThumb":"https:\/\/www.thecocktaildb.com\/images\/media\/drink\/zaqa381504368758.jpg","strIngredient1":"Cognac","strIngredient2":"Amaretto","strIngredient3":null,"strIngredient4":null,"strIngredient5":null,"strIngredient6":null,"strIngredient7":null,"strIngredient8":null,"strIngredient9":null,"strIngredient10":null,"strIngredient11":null,"strIngredient12":null,"strIngredient13":null,"strIngredient14":null,"strIngredient15":null,"strMeasure1":"1 1\/2 oz ","strMeasure2":"3\/4 oz ","strMeasure3":null,"strMeasure4":null,"strMeasure5":null,"strMeasure6":null,"strMeasure7":null,"strMeasure8":null,"strMeasure9":null,"strMeasure10":null,"strMeasure11":null,"strMeasure12":null,"strMeasure13":null,"strMeasure14":null,"strMeasure15":null,"strImageSource":null,"strImageAttribution":null,"strCreativeCommonsConfirmed":"No","dateModified":"2017-09-02 17:12:39"}]}

Unless changed in latest versions it should if you do ctl+c, not right click.

Maybe I didn’t notice because I was trying to select the text first. Either way, the response is above. I put that into the script and tried to parse it and I get the error.

image

comment out the json.parse line so you get get the raw json samba is using.

copy&paste that script here…

that test() wont work…
i meant your search script, return data with parse commented out

Not really sure what you’re getting at with test(), it has the data posted in as its being returned. If you want my script with the parse commented out then I need to comment out other logic. This is not the actual script since I’m returning the length normally.

Run searchresults(“french”)

//Get Cocktail Reults
function searchresults(name)
{
  var u = 'https://www.thecocktaildb.com/api/json/v1/1/search.php?s='+name;
  var data = web.Download(u);
  // var results = JSON.parse(data);
  var results_return = 0;
  
  // Get the number of results
  // if (results.drinks!=null) {
  //	results_return = results.drinks.length;
  // } else {
  // 	results_return = 0;
  // }

  return data;
}

image

There are errors in the returned json…
Unescapes quotes

San Francisco is returned in ‘fr’ but not ‘f’ and obviously not ‘fre…’

Doesn’t work for me. What is the link to the validator you’re using and what is the search you did?

‘json formatter’

Am on 5.3.0 on this machine.

CTRL+C when the return popup is open?

‘French 75’ has invalid chars, lookes like linebreak…

Checked your list for works and fails.
‘f’ doesnt return ‘French 75’ for some reason, perhaps they are pagnating returned results?
Your issue is invalid json from that site.