Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Create a User with API

  1. #1
    Join Date
    Nov 2016
    Posts
    2

    Default Create a User with API

    Hello,

    My version of pentaho is 5.3.
    I'm trying to use pentaho API to create a user.
    For now I can use the API of pentaho with the GET, but I can not manage to do a PUT.
    I try to do this in JAVA using HttpsUrlConnexion and here is how I proceed.

    PUT this is NOK

    url = new URL("https://xxxxx/pentaho/api/userroledao/createUser");
    // identification avec le ticket

    hsu2 = (HttpsURLConnection) url.openConnection(proxy);
    hsu2.setDoOutput(true);
    hsu2.setRequestMethod("PUT");
    // System.out.println(hsu2.getHeaderField("Set-Cookie"));
    hsu2.setRequestProperty("Cookie", cookies);
    hsu2.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
    hsu2.addRequestProperty("User-Agent", "Mozilla");
    hsu2.setRequestProperty("Connection", "keep-alive");
    hsu2.setRequestProperty("Content-Type","application/json");
    String json_create_user = "{\"userName\":\"user_name\",\"password\": \"password\"}";

    OutputStream os3 = hsu2.getOutputStream();
    os3.write(json_create_user.getBytes());
    os3.flush();
    os3.close();
    hsu2.disconnect();

    This return a error 500

    When i do a GET and this is OK

    url = new URL("https://xxxxx/pentaho/api/userroledao/users");
    // identification avec le ticket
    hsu2 = (HttpsURLConnection) url.openConnection(proxy);
    hsu2.setDoOutput(true);
    hsu2.setRequestMethod("PUT");
    // System.out.println(hsu2.getHeaderField("Set-Cookie"));
    hsu2.setRequestProperty("Cookie", cookies);
    hsu2.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
    hsu2.addRequestProperty("User-Agent", "Mozilla");
    hsu2.setRequestProperty("Connection", "keep-alive");
    hsu2.setRequestProperty("Content-Type","application/json");

    hsu2.disconnect();

    This return users of pentaho in xml format.



    I used the API documentation but still the PUT does not work..

    Thank's

    Guillaume D

  2. #2

    Default

    I realize this is a stale thread, but I found it after encountering a similar problem. The endpoint only appears to accept XML content. What succeeded for me was a PUT against pentaho/api/userroledao/createUser with content type application/xml and a body like this:

    <user>
    <userName>TestUser</username>
    <password>TestPassword</password>
    </user>

    I figured this out solely by making some educated guesses after noticing the docs only specified application/xml as an acceptable request body type. There is no documentation providing this actual XML structure that I could find. Even using Postman, trying to submit the userName and password on separate lines without XML decoration as shown at https://help.pentaho.com/Documentati...#Create_a_user failed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.