Simple Rest Connector with input and output parameters

I need to build very simple model with desktop modeler ,
to call this following GET API call [https://jsonplaceholder.typicode.com/users/1]
and read the following result :
{
“id”: 1,
“name”: “Leanne Graham”,
“username”: “Bret”,
“email”: “Sincere@april.biz”,
“address”: {
“street”: “Kulas Light”,
“suite”: “Apt. 556”,
“city”: “Gwenborough”,
“zipcode”: “92998-3874”,
“geo”: {
“lat”: “-37.3159”,
“lng”: “81.1496”
}
},
“phone”: “1-770-736-8031 x56442”,
“website”: “hildegard.org”,
“company”: {
“name”: “Romaguera-Crona”,
“catchPhrase”: “Multi-layered client-server neural-net”,
“bs”: “harness real-time e-markets”
}
}

I want to pass parameter userid = 1 and the get the result via parameters

How to configure connector for that , I read the docs, but it is very unclear for new users

================

Hi @omar-awwad

userId is a path parameter (not a query parameter)

so userId is supposed to be defined as a variable before the Rest Connector step.

and the URL of the connector step can be set as follows

Thank @hassang for your reply , it worked fine.

Now, I have the input parameter “userId” and output parameters: name, email, body as shown below :

I want to build test c# windows app that creates instance of the same model above, passes a value for the userId parameter, runs the instance and returns the parameter values (returnedName , returnedEmail)

As I read, I need to call Zebee Rest Api for that Any help on that ?

Thanks for your help.

The following community zeebe client can be used

You can find a simple example in below API Docs page

https://camunda-community-hub.github.io/zeebe-client-csharp/

Thank you for help,
I will try the client

1 Like

I tried the following code for zebee client:


I passed the value for the variable userID = “3” ,

But in the model, it is hardcoded to “1”


If I remove the assignment value, I get error above.

the running instance , it always take the hardcoded value “1”

How to pass value for the variable from code and read returned variable result also in code ?

Hi @omar-awwad,

The output assignment will override the value set by the code so simply remove the output entry from the model.

The variable will be created and set programmatically.

Thank you @hassang for your support ,
I can send parameter from code as needed ,

Now , how to read output parameters from code ?

Hi @omar-awwad

You can create an instance with results as follows

final ProcessInstanceResult processInstanceResult =
    client
        .newCreateInstanceCommand()
        .bpmnProcessId(bpmnProcessId)
        .latestVersion()
        .withResult() // to await the completion of process execution and return result
        .send()
        .join();

https://docs.camunda.io/docs/apis-tools/java-client-examples/process-instance-create-with-result/#processinstancewithresultcreatorjava

Thanks very much for help , @hassang
It worked perfectly.

Now, I will add more features for my app

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.