Designer
Last updated
Last updated
For this guide, we will need the following:
An project
An instance
Please return here when you are ready.
We will define a new workflow called GetUser
. The purpose of the workflow is to handle inbound HTTP requests by fetching a user by a given user ID from a backend API and writing them back to the client in JSON format.
For the backend API, we will use , which returns fake data using real HTTP responses.
Our workflow will parse the inbound HTTP request by getting the desired user ID from a route parameter and use that value to make an API call to reqres.
The response should look similar to this:
Our workflow will essentially be a proxy sitting in front of the reqres API and return a portion of the response.
Follow these steps to create the workflow using Elsa Studio.
Configure the activities as follows:
HTTP Endpoint
Path
users/{userid}
Default
Supported Methods
Get
Default
Set Variable
Variable
UserId
Default
Value
return Variables.RouteData["userid"];
C#
HTTP Request (flow)
Expected Status Codes
200, 404
Default
Url
return $"https://reqres.in/api/users/{Variables.UserId}";
C#
Method
GET
Default
HTTP Response (200)
Status Code
OK
Default
Content
variables.User.data
JavaScript
HTTP Response (404)
Status Code
NotFound
Default
Content
User not found
Default
The final result should look like this:
Since the workflow uses the HTTP Endpoint activity, it will trigger when we send an HTTP request to the /api/workflows/users/{userId} path.
The response should look similar to this:
In this guide, we learned how to design a workflow using Elsa Studio.
We leveraged the HttpEndpoint
activity and used is as a trigger to start the workflow.
The workflow is able to read route parameters and store it in a variable, which we then used as an input to send an API call to the reqres API that in turn returns the requested user.
We have also seen how to handle various responses from reqres: 200 OK and 404 Not Found
The following is an example of such an HTTP request that you can try right now from your browser:
Try it out by navigating to .
The workflow created in this guide can be found .