5 Replies Latest reply on Feb 19, 2019 10:40 PM by Sanford Whiteman

    How to set scriptingObjects when script block token created through api

    Sham Chikkegowda

      Creating the script token using the end point /rest/asset/v1/folder/{id}/tokens.json?folderType=Program as attached. Token created fine. When try to use that in email template throwing the error "No usable value for scriptingObjects Expected object but got JString()". If i create the same token manually email delivers fine. The difference between API & Manual Creation is below

       

      API Response

      {"name":"test","type":"script block","value":"{\"codeBlock\":\"#set($ed1 = \\\"ok\\\")\",\"scriptingObjects\":\"\"}"}

       

      Manual One

      {"name":"test","type":"script block","value":"{\"codeBlock\":\"#set($ed1 = \\\"ok\\\")\",\"scriptingObjects\":{}}"}

       

      So how to set scriptingObjects through api call ?

       

       

      API.png

      Thanks for your time.

       

      cc:Sanford Whiteman

        • Re: How to set scriptingObjects when script block token created through api
          Sanford Whiteman

          Can't repro this. scriptingOptions isn't part of the API contract and isn't required to send an email that includes the VTL {{my.token}}.

           

          I note that your token doesn't output anything. Is there another, later token drawing on this one for output? Is the token truly in the template? Where is it placed exactly?

            • Re: How to set scriptingObjects when script block token created through api
              Sham Chikkegowda

              Thanks Sanford Whiteman for faster quickly.    We went with solution & validate in Sandbox & QA Environment where it worked fine. But in production it is not working.  The error message matches with difference we are seeing in scriptingOption.   Also scriptingOption missing in other environment also but still works.  

               

              You are right Currently token just sets the event description. This is first token added in template. Later we have business logic drawing on that variable to render different variation. Just for debug in production template just added {{my.test:default=}}  It throws "No usable value for scriptingObjects Expected object but got JString()".

               

              Some additional info we gathered during debug & might give some hints

              Please note  in problematic environment

              1. If i use schedule campaign the same template works when token is created through API. 
              2. We are using is triggered campaign ( lead is pushed from api) & throwing the error .  
              3. If i create the token manually rather than setting through api the same template works for triggered campaign

               

              Any clue you can provide is highly appreciated ?  Also engaged official support  just tagging without much progress.

               

              Thanks in advance.

              1 of 1 people found this helpful