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
Start with official doc... it's pretty simple and you have on hands tutorials about it...
docs.appian.com/.../Web_API_Tutorial.html
Please follow the below link. docs.appian.com/.../Ways_to_Start_a_Process_From_a_Process.html
When creating a new web API, there is a template to start a process.
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)*/ /*)*/ ))
salinis said: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.
salinis said:also i need guidance how it can be authenticated
https://docs.appian.com/suite/help/24.4/Web_API_Authentication.html