Create users using webapi

Certified Senior Developer

I have a requirement in which I need to create a webapi which will create users in appian.In webapi,we are providing the userid as an input and with that Id I need to invoke a processmodel which will create user in appian and add the user to respective groups.Iam a beginner to api ,so need  guidance for this.Appreciate if anyone can help on this.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    When creating a new web API, there is a template to start a process.

  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    Thanks for the guidance...I created webapi using start process template and it is working fine..Next concern is how the parameters(wwid,firstname,lastname,email,role)which i passed in body  will come from external system to webapi?also i need guidance how it can be authenticated

    a!localVariables(
      local!data:if(
        isnull(http!request.body),
        {},
        a!fromJson(http!request.body)
      ),
      a!startProcess(
      processModel: cons!MDA_ADD_USER,
      /* A dictionary or map of parameters passed to the process model */
      processParameters: {
        wwid: local!data.wwid,
        firstname: local!data.firstname,
        lastname: local!data.lastname,
        email: local!data.email,
        role: local!data.role
      },
      isSynchronous: false(),
      /* This expression will run when the process is started (when run asynchronously) or completed (when run synchronously) */
      onSuccess: a!httpResponse(
        statusCode: 200,
        headers: {
          a!httpHeader(
            name: "Content-Type",
            value: "application/json"
          )
        },
        body: if(
          a!isNotNullOrEmpty(fv!processInfo),
          a!toJson(fv!processInfo),
          null()
        )
      ),
      /* This expression will run if the process fails to start */
      onError: a!httpResponse(
        statusCode: 500,
        headers: {
          a!httpHeader(
            name: "Content-Type",
            value: "application/json"
          )
        },
        body: a!toJson(
          {
            error: "There was an error starting the process"
          }
        )
      ),
      /* If the process is started synchronously, this expression will run if the process does not complete in 30 seconds */
      /*onIncomplete: a!httpResponse(*/
      /*statusCode: 504,*/
      /*headers: {*/
      /*a!httpHeader(*/
      /*name: "Content-Type",*/
      /*value: "application/json"*/
      /*)*/
      /*},*/
      /*body: a!toJson(fv!processInfo)*/
      /*)*/
      
    ))

  • 0
    Certified Lead Developer
    in reply to salinis
    Next concern is how the parameters(wwid,firstname,lastname,email,role)which i passed in body  will come from external system to webap

    Not sure what you mean. Line 2 parses the JSON string from the HTTP body.

    also i need guidance how it can be authenticated

    https://docs.appian.com/suite/help/24.4/Web_API_Authentication.html

Reply Children
No Data