Importing Users, Groups and Roles in Batches

<< Click to Display Table of Contents >>

Current:  System Integration > WebAPI 

Importing Users, Groups and Roles in Batches

Previous pageReturn to chapter overviewNext page

Request address

http://ip:port/bi/api?action=saveNode&type=all&token=xxxx

Request message

Request parameter

Request Parameters: xmlData(required)

<?xml version="1.0" encoding="UTF-8"?>

<info>

  <users >

     <user>

        <name>hunk1</name><pass></pass>

        <email>test@qq.com</email>

        <parent></parent><roles></roles>

     </user>

  </users>

  <groups>

     <group>

        <name>testabc</name>

        <parent>test11</parent><roles></roles>

     </group>

  </groups>

  <roles>

     <role>

        <name>test2_role1</name>

     </role>

  </roles>

</info>

or

<?xml version="1.0" encoding="UTF-8"?>

<info>

  <users >

     <user isOverWrite="true">

        <name>hunk1</name><pass>asdf</pass>

        <email>test@qq.com</email>

        <parent></parent><roles></roles>

     </user>

  </users>

  <groups>

     <group>

        <name>testabc</name>

        <parent>test11</parent><roles></roles>

     </group>

  </groups>

  <roles>

     <role>

          <name>test2_role1</name>

     </role>

  </roles>

</info>

parametric description

1) You can add multiple users, groups and roles in the request parameters at the same time, and set the relationship between them. The prerequisite is to ensure that the associated information must be in the added information or in the system.

2) The user, group and role attribute information are the same as the interface for adding users, adding groups and adding roles.

Sample

function initData() {

  var xml = getXml();

  $.post("http://" + ip + ":" + port + "/" + project + "/api?action=saveNode&type=all&token=xxxx",

     {xmlData : xml},

     function(result) {

     writeXml(result);

  });

}

Response message

Response result

 

1) Successful operation

<?xml version="1.0" encoding="UTF-8"?>

<results>

 <result>

         <level>1</level>

         <message>group{testabc}: Operates successfully. </message>

 </result>

 <result>

         <level>1</level>

         <message>role{test2_role1}:Operates successfully. </message>

 </result>

 <result>

         <level>1</level>

         <message>user{hunk1}: Operates successfully. </message>

 </result>

</results>

2) Operation failed

<?xml version="1.0" encoding="UTF-8"?>

<results>

 <result>

         <level>6</level>

         <message>group{testabc}: Folder not found:“g2”.</message>

 </result>

 <result>

         <level>6</level>

         <message>role{test2_role1}: Id already exists.</message>

 </result>

         <result>

         <level>6</level>

         <message>user{hunk1}: Id already exists.</message>

  </result>

</results>

Result description

The response result information is xml. direct parse.

1) Level return type, different values represent different return status, see appendix.

2) Message is the interface operation result information.