5 Replies Latest reply on Mar 6, 2018 12:39 AM by Yudi Maryanto

    Create CLM User using ReST API

    Yudi Maryanto

      Hi,

       

      I can retrieve CLM users using REST API but I have difficulties on creating CLM User using REST API. I think I have followed all the instruction on the CLM REST API documentation but I always end up receiving java.lang.IllegalArgumentException.

       

      Here is my HTTP request and response. Please show me what I've missed

       

      Thanks

       

      clm-request.PNG

       

      clm-response.PNG

        • 1. Re: Create CLM User using ReST API
          Devendra Dehadaraya

          Hi,

           

          The POST API to create user is --> <http/https>://<Platform manager machine name>:<port>/csm/User/Create


          Input request body is -->

           

          {

          "timeout": -1,

          "operationParams": [{

          "name": "user",

          "value": {

          "cloudClass": "com.bmc.cloud.model.beans.User",

          "description": "create call",

          "firstName": "test2",

          "lastName": "tester2",

          "email": "tes1@bmc.com",

          "customFieldsObject": [{

          "cloudClass": "com.bmc.cloud.model.beans.CustomField",

          "name": "ctm_people.1000001437",

          "description": "TemplateName",

          "stringValue": "Cloud Organization Admin", --> Same role name as seen in the CLM Admin Console

          "type": "String"

          }

          ],

          "name": "test2",

          "password": "plaintext:password",

          "primaryOrganization": "<Organization Name>",

          "foundationLocationObject": {

          "cloudClass": "com.bmc.cloud.model.beans.FoundationLocation",

          "name": "<Site Name>"

          }

          },

          "type": "com.bmc.cloud.model.beans.User",

          "multiplicity": "1"

          }, {

          "name": "isRemote",

          "value": true,

          "type": "java.lang.Boolean",

          "multiplicity": "0..1"

          }

          ],

           

           

          "postCallout": "",

          "callbackURL": "",

          "preCallout": ""

          }

          • 2. Re: Create CLM User using ReST API
            Yudi Maryanto

            Hi Devendra,

             

            I have tried your suggestion, but I still got "IllegalArgumentException". From "csm.log" file, I saw that the previous exception is "java.lang.NullPointerException". It seems that some expected fields were missing from my JSON request. But unfortunately, BMC didn't tell us what fields were missing.

             

            Do you have any idea what's wrong with my JSON request?

             

            clm2-error00.PNG

            clm2-error01.PNG

             

            on "csm.log" file, the first exception is "java.lang.NullPointerException", followed by "java.lang.IllegalArgumentException"

            clm2-error02.PNG

             

            clm2-error03.PNG

            • 3. Re: Create CLM User using ReST API
              Yudi Maryanto

              Finally, I found what's wrong with my JSON after (unfortunately) I reverse engineering the jar file and examined the java source code. As the log file stated that there was "NullPointerException" on "CsmRequestParser.java" line 313. On the source code, we can see that it tries to retrieve "multiplicity" parameter. Therefore, I check all "multiplicity" occurrences on my JSON request and found that there was one misspelled "multiplicity'. After correcting this, now I can create user using REST API.

               

              I think BMC should give clearer error message here, considering so many json attributes in a single request. Only stating that there was "NullPointerException" will make it difficult for us to determine which json attributes are missing. It took me a day to figure out what was missing

               

              BMC Should give error message something like Missing 'multiplicity' attribute for 'isRemote' on 'operationParams'. It will hugely save us from headache and time consuming of guessing what was missing.

               

              Thanks a lot for Devendra Dehadaraya

              null.PNG

              • 4. Re: Create CLM User using ReST API
                Devendra Dehadaraya

                Its great that you got what the issue is. If you try with the JSON which I have sent above, things should work. It does have the multiplicity defined for each operationParams.

                 

                Few issues in you JSON request is ->

                 

                1. You are not mentioning what is the type of the password (plain/encrypted)
                2. To which organization does the user belongs to. - (It might be allocating a default organization)
                3. What is the role - (Default it might be taking Cloud End User)

                 

                It is better to mention the above points in JSON since when you are creating many users, it is important to place them in the right organization and assign them a desired role.

                • 5. Re: Create CLM User using ReST API
                  Yudi Maryanto

                  Thanks for the information Devendra Dehadaraya

                  Devendra Dehadaraya wrote:

                   

                  Few issues in you JSON request is ->

                  1. You are not mentioning what is the type of the password (plain/encrypted)
                  2. To which organization does the user belongs to. - (It might be allocating a default organization)
                  3. What is the role - (Default it might be taking Cloud End User)

                  This really should be mentioned in the documentation along with sample request & response. But I cannot find these requirement on the create user API documentation User create request - Documentation for BMC Cloud Lifecycle Management 4.6 - BMC Documentation

                   

                  I think, to be a good API documentation, all section that is callable API must include sample request/response (HTTP and JSON). Because for BMC employees, some required parameters might seem quite obvious not to be omitted. But for someone that is completely new to this API, those required parameters might be missed and lead to frustration and tedious and time-consuming troubleshooting.

                  1 of 1 people found this helpful