m_b
m_b

Reputation: 51

failed to execute javascript command via HTTP API

I'm trying to execute javascript command via HTTP API as follows:

    curl -X POST -H "Content-Type:application/json" -H "Authorization:Basic 
    YWRtaW46aWRlYWw0ODI2" -H "Cache-Control:no-cache" -d '{ "transaction" : true, 
      "operations" : [ 
        {
          "type" : "script",
          "language" : "javascript",
          "script" : "orient.getGraph().createVertex('class:customer')"
        }
      ]
    }' http://localhost:2480/batch/mydb

response came as follows:

com.orientechnologies.orient.core.exception.OSecurityException: Language 'javascript' is not allowed to be executed

version details(http response):
Server →OrientDB Server v.1.7.8 (build UNKNOWN@r${buildNumber}; 2014-08-13 15:56:07+0200)

What is wrong with it!?
Thank you

Upvotes: 0

Views: 442

Answers (1)

Lvca
Lvca

Reputation: 9060

This is for security reasons. To allow JS scripts open config/orientdb-server-config.xml file and change the OServerSideScriptInterpretercomponent:

    <!-- SERVER SIDE SCRIPT INTERPRETER. WARNING! THIS CAN BE A SECURITY HOLE:
        ENABLE IT ONLY IF CLIENTS ARE TRUCT, TO TURN ON SET THE 'ENABLED' PARAMETER
        TO 'true' -->
    <handler
            class="com.orientechnologies.orient.server.handler.OServerSideScriptInterpreter">
        <parameters>
            <parameter name="enabled" value="true"/>
            <parameter name="allowedLanguages" value="SQL,Javascript"/>
        </parameters>
    </handler>

Upvotes: 2

Related Questions