AnsweredAssumed Answered

I can not create a user on PENTAHO via the POST method

Question asked by hicham hanine on Feb 14, 2018

I tried to create a user on PENTAHO via the POST method

01.png

I tried to make a call from REST API (test01.jsp)

<input type="button" id="text-id" value="Bouton à cliquer" onclick="submitTest();"> 
<script>  function submitTest(){ var http = new XMLHttpRequest();
var url ="http://127.0.0.1:8088/pentaho/api/userroledao/createUser";
var params ="userName=user01&password=user02";
http.open("POST", url, true);
http.setRequestHeader("application","application/x-www-form-urlencoded");
http.onreadystatechange= function() {
if(http.readyState == 4 && http.status == 200) { alert(http.responseText);}
}
http.send(params);}

 

and I make a call with the following link

http://server:port/pentaho-style/test01.jsp

and when I click on the button I receive this error:

02.png

For information, I modify the following files:

biserver-ee\pentaho-solutions\system\pentaho-cdf-dd\settings.xml biserver-ee\pentaho-solutions\system\pentaho-cdf\settings.xml

by adding the following line:

<allow-cross-domain-resources>true</allow-cross-domain-resources>

And on the file

biserver-ce\tomcat\conf\web.xml

by adding the following line:

<filter> 
     <filter-name>CorsFilter</filter-name>
     <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
     <init-param>
          <param-name>cors.allowed.origins</param-name>
          <param-value>*</param-value>
     </init-param>
     <init-param>
          <param-name>cors.allowed.methods</param-name>
          <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
     </init-param>
     <init-param>
          <param-name>cors.allowed.headers</param-name>
          <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Allow-Origin,
          Access-Control-Request-Method,Access-Control-Request-Headers
</param-value>
     </init-param>
     <init-param>
          <param-name>cors.exposed.headers</param-name>
          <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
     </init-param>
     <init-param>
          <param-name>cors.support.credentials</param-name>
          <param-value>true</param-value>
     </init-param>
     <init-param>
          <param-name>cors.preflight.maxage</param-name>
          <param-value>10</param-value>
     </init-param>
</filter>

<filter-mapping>
     <filter-name>CorsFilter</filter-name>
     <url-pattern>/*</url-pattern>
</filter-mapping>

For information, if I remove the following line:

http.setRequestHeader("application", "application/x-www-form-urlencoded");

I receive the same error

Outcomes