Cloud Development Kit

_mathParameters property in myscript-math-web does not work

I need to be able to set userResources in the math web component. The docs suggest the following should work:

<myscript-math-web id="mathInput"

                             host="cloud.myscript.com"

                             applicationkey="*******"

                             hmackey="**********"

                             _mathParameters="{ userResources: ['my_resource'] }"

                             ></myscript-math-web>

But the mathParameters.userResources property is not set on the request.


Dear Samuel,


thank you for contacting us.


Did you compile and set your custome grammar as explained into the following post: https://developer-support.myscript.com/support/discussions/topics/16000007796


Also, are you getting an error message? If so, can you please provide it?


Thank you,


Best regards,


Olivier


Yes, and I have confirmed it works by adding to the request manually:

    var _sendMessage = function (socket, message) {

        if (socket) {

          if (message.parameters && message.parameters.constructor.name === 'MathParameter'){

            message.parameters.userResources = ['my_resource'];

          }

            socket.send(JSON.stringify(message));

        }

    };

But I can't seem to pass it down from the top.

There is no error message, the property is just not set.

Dear Samuel,


currently, it is not possible to add custom grammars with the Web Components.


To use a custom grammar, you should set it in the paramaters of your REST or WebSocket query: https://developer-support.myscript.com/support/discussions/topics/16000007796


Best regards,


Olivier

Dear Samuel,

can you please try as follows:

<!DOCTYPE html>

<head>
  <script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
  <link rel="import" href="bower_components/myscript-math-web/myscript-math-web.html">
  <style>
  body {
  height: 98vh;
  width: 98vw;
  }
   
  myscript-math-web {
  height: 100%;
  width: 100%;
  }
  </style>
</head>

<body>
  <myscript-math-web host="cloud.myscript.com" applicationkey="<YOUR KEY>" hmackey="<YOUR HMAC KEY>">
  </myscript-math-web>
  <script>
  window.addEventListener('load', () => {
  console.log('load');
  console.log(document.querySelector('myscript-math-web')._mathParameters.userResources);
  document.querySelector('myscript-math-web')._mathParameters.userResources = ['myCustomRessource'];
  console.log(document.querySelector('myscript-math-web')._mathParameters.userResources);


  })
  </script>
</body>

</html>

Best regards,

Olivier

I prints what you expect, i.e.:

'load'

[]

['myCustomResource']

But by the time the message is sent the key has been deleted:

var _sendMessage = function (socket, message) {

        if (socket) {

          if (message.parameters && message.parameters.constructor.name === 'MathParameter'){

          console.log(message.parameters)  

         }

            socket.send(JSON.stringify(message));

        }

    };


...shows the parameters key is empty

Dear Samuel,

we are facing issues figuring out what is causing this behavior and what you are trying to achieve.

Is it possible to get your whole project, so that we can better understand?

Thank you,

Best regards,

Olivier

I am using the library here: https://github.com/MyScript/web-integration-samples/tree/master/web-samples with zero changes, apart from using my own auth credentials and adding the line 


    _mathParameters='{ "userResources": ["my_resource"] }'


to the math component in index.html, like I said in my first post.


I'm not trying to do anything more complicated at the moment. 

Dear Samuel,


the default sample while using a custom grammar is working fine on our side.


What are you trying to achieve with your "if" : if (message.parameters && message.parameters.constructor.name === 'MathParameter') ?


Best regards,


Olivier

Hmm, well something is different. Here is my code: https://github.com/g-sam/web-integration-samples/tree/bug-demo. Please add credentials in index.html then tell me if it works for you. Also, please post the contents of the sent message object, or message.parameters. Alternatively, please link me to your working implementation.

The 'if' was to log out math requests only, but you can remove it, the results are the same.


Hi Samuel,
You have to use javascript property instead of HTML propert.
Let me know if it works,
Login or Signup to post a comment