You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: "Presents an overview of consumed REST services and JSON in Mendix."
4
+
description: "Describes how to interact with REST APIs in Mendix and build REST requests."
5
5
weight: 15
6
6
#If moving or renaming this doc file, implement a temporary redirect and let the respective team know they should update the URL in the product. See Mapping to Products for more details.
7
7
---
8
8
9
9
## Consumed REST Services
10
10
11
-
Mendix offers different features which allow you to interact with any REST API. You can use them to build and test your REST requests or create data structures in your project.
11
+
Mendix offers features that allow you to interact with any REST API. You can use them to build and test your REST requests or create data structures in your project.
12
12
13
13
## Read More
14
14
15
-
*[Consumed REST Service](/refguide/consumed-rest-service/), an overview on how to Consume a REST Service document
16
-
*[Import an OpenAPI/Swagger contract](/refguide/consumed-rest-service/#installation), instructions on how to create a Consumed REST Service from an OpenAPI/Swagger contract
17
-
*[Call REST Service](/refguide/call-rest-action/), a description of the microflow action
18
-
*[Use Call REST Service Action in a Microflow](/refguide/integration/use-call-rest-action-in-microflow/), instructions on how to use the Call REST Service action in a microflow
19
-
*[HttpRequest and HttpResponse System Entities](/refguide/http-request-and-response-entities/), an overview of these system entities in your domain model
15
+
*[Consumed REST Service](/refguide/consumed-rest-service/) – Describes how to consume a REST service
16
+
*[Import an OpenAPI/Swagger contract](/refguide/consumed-rest-service/#installation) – Describes how to create a consumed REST service from an OpenAPI/Swagger contract
17
+
*[Call REST Service](/refguide/call-rest-action/) – Describes the Call REST Service microflow action
18
+
*[Use Call REST Service Action in a Microflow](/refguide/integration/use-call-rest-action-in-microflow/) – Describes how to use the Call REST Service action in a microflow
19
+
*[HttpRequest and HttpResponse System Entities](/refguide/http-request-and-response-entities/) – Describes these system entities in your domain model
Copy file name to clipboardExpand all lines: content/en/docs/refguide/modeling/integration/rest-services/consumed-rest-services/consumed-rest-service.md
+37-37Lines changed: 37 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Consumed REST Service"
3
3
url: /refguide/consumed-rest-service/
4
-
description: "Describes the configuration and usage of the new Consumed REST service document."
4
+
description: "Describes how to configure and use the Consumed REST Service document."
5
5
weight: 5
6
6
aliases:
7
7
- /refguide/consumed-rest-services-beta/
@@ -10,17 +10,17 @@ aliases:
10
10
11
11
## Introduction
12
12
13
-
Use the Consumed REST Service document to send REST requests from Mendix Studio Pro. With this feature, you can build, test, and create data structures to store your requests.
13
+
Use the Consumed REST Service document to send REST requests from Studio Pro. With this feature, you can build, test, and create data structures to store your requests.
14
14
15
15
{{% alert color="info" %}}
16
16
The Consumed REST Service document is released for general availability (GA) for Windows only. This feature is still in beta for macOS and will be released for GA at a later date.
17
17
{{% /alert %}}
18
18
19
19
### Use Cases
20
20
21
-
Use the Consumed REST Service document to do the following:
21
+
You can use the Consumed REST Service document to do the following:
22
22
23
-
* Consume a REST Service manually or from an OpenAPI/Swagger contract
23
+
* Consume a REST service manually or from an OpenAPI/Swagger contract
24
24
* Configure `GET`, `POST`, `PUT`, `PATCH`, and `DELETE` requests
25
25
* Create entities directly in the domain model
26
26
* Send REST requests through a microflow
@@ -31,18 +31,18 @@ The ability to import an OpenAPI/Swagger contract is currently in beta.
31
31
32
32
### Limitations
33
33
34
-
* To use the request response to create a data structure automatically in your domain model, the response data should be in JSON format. It is possible to process other formats, such as XML or raw text, but you will need to extract the data you are looking for in a microflow.
35
-
*It is currently not possible to configure parameters in the Query Parameters tab.
36
-
* Streaming responses from APIs are currently not supported.
37
-
* A response can be mapped in a microflow only for responses with status code `200`. If a Send REST request action is executed in a microflow and the status code is in 2xx range, but different than `200`, use the latestHttpResponse to get the status code and response content.
34
+
* To use the request response to create a data structure automatically in your domain model, the response data must be in JSON format. You can process other formats, such as XML or raw text, but you need to extract the data in a microflow.
35
+
*You cannot configure parameters in the Query Parameters tab.
36
+
* Streaming responses from APIs are not supported.
37
+
* A response can be mapped in a microflow only for responses with status code `200`. If a Send REST request action is executed in a microflow and the status code is in the 2xx range but different than `200`, use the latestHttpResponse to get the status code and response content.
38
38
39
39
### Prerequisites
40
40
41
41
* Familiarity with [HTTP request methods](https://www.w3schools.com/tags/ref_httpmethods.asp)
42
42
43
43
## Add the Consumed REST Service Document {#installation}
44
44
45
-
Download [Studio Pro](https://marketplace.mendix.com/link/studiopro/) and add the Consumed REST Service document to your app. To do this, follow these steps:
45
+
Download [Studio Pro](https://marketplace.mendix.com/link/studiopro/) and add the Consumed REST Service document to your app by doing the following:
46
46
47
47
1. Right-click the module you want to add the Consumed REST Service document to.
@@ -63,9 +63,9 @@ For more information about importing from an OpenAPI/Swagger contract, see the [
63
63
64
64
## Configuration {#configuration}
65
65
66
-
Use the Consumed REST Service to configure a `GET`, `POST`, `PUT`, `PATCH`, or `DELETE` request for your app. A request can be configured manually or by uploading an OpenAPI or Swagger contract.
66
+
Use the Consumed REST Service to configure a `GET`, `POST`, `PUT`, `PATCH`, or `DELETE` request for your app. You can configure a request manually or by uploading an OpenAPI or Swagger contract.
67
67
68
-
If you upload an OpenAPI URL or Swagger contract, the content of the URL or file will be automatically added to your consumed REST service document. You can still manually configure the request after upload, such as add new [parameters](#add-parameters), [headers](#add-headers), or create entities from the request/response.
68
+
If you upload an OpenAPI URL or Swagger contract, the content of the URL or file is automatically added to your consumed REST service document. You can still manually configure the request after upload, such as adding new [parameters](#add-parameters), [headers](#add-headers), or creating entities from the request/response.
69
69
70
70
### Basic Configuration {#configure-a-request}
71
71
@@ -84,13 +84,13 @@ Create a `GET`, `POST`, `PUT`, `PATCH`, or `DELETE` request to send data to your
84
84
To make the base URL dynamic, see the [Dynamic Base URL](#dynamic-base-url) section below.
85
85
86
86
5. Click **Authentication**.
87
-
6. Select an authentication method, then click **OK**. For more information, see [Authentication methods](#authentication).
87
+
6. Select an authentication method, then click **OK**. For more information, see [Authentication Methods](#authentication).
You can visualize your request in the **Response** tab, then use the response to [create an entity in the domain model](#create-entity).
93
+
You can visualize your request in the **Response** tab and use the response to [create an entity in the domain model](#create-entity).
94
94
95
95
### Import from OpenAPI/Swagger Contract {#open-api-import}
96
96
@@ -128,9 +128,9 @@ Parameters are not supported in the Authentication section.
128
128
129
129
{{% /alert %}}
130
130
131
-
Parameters are fully supported in the path and query part of the URL, in the header value, and in the body. They are defined within curly brackets. For example, in the URL, defining `number` as parameter would be `http://numbersapi.com/{number}`. The parameters that are configured for the URL, headers, or body within curly brackets are automatically added to the parameters grid.
131
+
Parameters are fully supported in the path and query part of the URL, in the header value, and in the body. They are defined within curly brackets. For example, in the URL, defining `number` as a parameter would be `http://numbersapi.com/{number}`. The parameters that are configured for the URL, headers, or body within curly brackets are automatically added to the parameters grid.
132
132
133
-
You can manually add new parameters to the parameters grid directly. To do so, follow these steps:
133
+
You can manually add new parameters to the parameters grid. To do so, follow these steps:
134
134
135
135
1. Open the **Parameters** tab and click **Add parameter**.
136
136
2. Name your parameter and add a test value.
@@ -144,12 +144,12 @@ You can manually add new parameters to the parameters grid directly. To do so, f
144
144
You can add a Base URL as a parameter. To do this, follow these steps:
Your base URL is now considered as a parameter. You can change its value in the [Send REST Request](/refguide/send-rest-request/) microflow activity.
152
+
Your base URL is now a parameter. You can change its value in the [Send REST Request](/refguide/send-rest-request/) microflow activity.
153
153
154
154
#### Adding Query Parameters
155
155
@@ -165,7 +165,7 @@ Parameters are not supported in the Query Parameters table.
165
165
166
166
{{% /alert %}}
167
167
168
-
Query parameters can be configured in the **Parameters** tab in the **Query Parameters** table. You can define them directly in the URL or add them manually in the Query parameters field.
168
+
Query parameters can be configured in the **Parameters** tab in the **Query Parameters** table. You can define them directly in the URL or add them manually in the **Query parameters** field.
169
169
170
170
##### Adding Query Parameter to URL
171
171
@@ -177,17 +177,17 @@ To add multiple parameters, add an ampersand (&) between each parameter, joining
177
177
178
178
##### Manually Add Query Parameters
179
179
180
-
You can manually add new query parameters directly to the Query parameters grid. To do this, follow the steps below:
180
+
You can manually add new query parameters directly to the **Query parameters** grid by doing the following:
181
181
182
182
1. Open the **Parameters** tab.
183
183
2. Click **Add query parameter**.
184
184
3. Name your query parameter and add a test value.
185
185
186
-
In this case, the newly configured query parameter will be automatically added to the URL.
186
+
The newly configured query parameter is automatically added to the URL.
187
187
188
-
By default, when a new query parameter is added to the grid, it is configured as a **Required** query parameter. You can change this setting to **Not required** by clicking the drop-down and changing the value of the required property to **No**.
188
+
By default, when you add a new query parameter to the grid, it is configured as **Required**. You can change this setting to **Not required** by clicking the drop-down and changing the value of the required property to **No**.
189
189
190
-
To include or exclude a query parameter from the URL, check or uncheck the checkbox of the specific query parameter.
190
+
To include or exclude a query parameter from the URL, select or clear the checkbox for that query parameter.
191
191
192
192
### Adding Headers {#add-headers}
193
193
@@ -205,9 +205,9 @@ You can also add a parameter as the test value of a header, as seen below. For e
### Adding a Request Body (for POST, PUT, and PATCH requests only) {#add-a-request-body}
208
+
### Adding a Request Body (for POST, PUT, and PATCH Requests Only) {#add-a-request-body}
209
209
210
-
`POST`, `PUT`, and `PATCH` requests support sending text as as a request body. Multiple formats are supported.
210
+
`POST`, `PUT`, and `PATCH` requests support sending text as a request body. Multiple formats are supported.
211
211
212
212
#### Request Body That Sends Static Text
213
213
@@ -217,17 +217,17 @@ If the request body content is static, paste the text into the **Body** tab. Thi
217
217
218
218
#### Adding a Request Body Using Parameters
219
219
220
-
When the text in the Body tab contains a parameter name surrounded by curly braces, it is interpreted as a parameter. These parameters can be used to change the body content dynamically.
220
+
When the text in the **Body** tab contains a parameter name surrounded by curly braces, it is interpreted as a parameter. You can use these parameters to change the body content dynamically.
For example, if your body content is `product_curr={currency}&product_price={price}`, the parameters `currency` and `price` can be used to change the body content.
225
225
226
-
#### Request Body Where Content Comes From Multiple Entities
226
+
#### Request Body Where Content Comes from Multiple Entities
227
227
228
-
When you have a body in JSON format, you can create entities in the domain model that will provide the body content. This allows you to easily send a body with dynamic data.
228
+
When you have a body in JSON format, you can create entities in the domain model that provide the body content. This allows you to send a body with dynamic data.
229
229
230
-
Create body entities from a JSON snippet to your request by doing the following:
230
+
To create body entities from a JSON snippet for your request, do the following:
231
231
232
232
1. Click the **Body** tab and add your JSON string.
233
233
@@ -249,7 +249,7 @@ You can check the response of your request in the **Response data** tab.
249
249
250
250
#### Response is in JSON Format {#create-entity}
251
251
252
-
If the response is in JSON format and you want to use the response to create an entity, open the **Response structure** tab, which displays a preview of the response data:
252
+
If the response is in JSON format and you want to use it to create an entity, open the **Response structure** tab, which displays a preview of the response data:
@@ -260,29 +260,29 @@ The entity name is prefilled, but you can change it to a custom name. To create
260
260
261
261
You can also add a parameter in the request body by generating a data structure (entities) as input. If only a small part of the request is dynamic, you can use parameters directly in the JSON snippet.
262
262
263
-
You can choose to flatten and simplify the structure of your response. Enable this feature by selecting **Flatten and simplify structure**. For more information, see the [Simplifying and Flattening Response Data](#simplify-and-flatten) section below.
263
+
You can flatten and simplify the structure of your responseby selecting **Flatten and simplify structure**. For more information, see [Simplifying and Flattening Response Data](#simplify-and-flatten).
264
264
265
265
#### Response is Not in JSON Format {#processing-non-json}
266
266
267
267
When the response is not in JSON format, it cannot be converted automatically into entities. Instead, you can extract the data in a microflow.
268
268
269
-
When the [Send REST request](/refguide/send-rest-request/) action is executed in a microflow, it places the result into the variable `latestHttpResponse`. In `latestHttpResponse`, you can find the `StatusCode` and `Content` of the request that was made. From here, you can use microflow logic to extract the information. For example, if the response has XML formatting, you can use [Import Mapping](/refguide/import-mappings/) to read the data.
269
+
When the [Send REST request](/refguide/send-rest-request/) action is executed in a microflow, it places the result in the variable `latestHttpResponse`. In `latestHttpResponse`, you can find the `StatusCode` and `Content` of the request. You can then use microflow logic to extract the information. For example, if the response has XML formatting, you can use [Import Mapping](/refguide/import-mappings/) to read the data.
270
270
271
271
### Simplifying and Flattening Response Data {#simplify-and-flatten}
272
272
273
-
When you receive JSON data, the structure of the response is simplified and flattened where possible. This can be seen in the **Response structure** tab.
273
+
When you receive JSON data, the structure of the response is simplified and flattened where possible. You can see this in the **Response structure** tab.
274
274
275
-
For example, the URL `https://vpic.nhtsa.dot.gov/api/vehicles/getallmakes?format=json` returns vehicle information. It returns a JSON object that contains the property `Results` with a list of objects. Without simplification, when you click **Create entity**, you will get 3 entities. With simplification, only 2 entities are created that still contain all vehicle information.
275
+
For example, the URL `https://vpic.nhtsa.dot.gov/api/vehicles/getallmakes?format=json` returns vehicle information. It returns a JSON object that contains the property `Results` with a list of objects. Without simplification, when you click **Create entity**, you get three entities. With simplification, only two entities are created that still contain all vehicle information.
276
276
277
-
By default, simplification and flattening is enabled. To change this, uncheck the box **Flatten and simplify structure** on the **Response structure** tab before clicking the **Create entity** button.
277
+
By default, simplification and flattening is enabled. To change this, clear **Flatten and simplify structure** on the **Response structure** tab before clicking **Create entity**.
278
278
279
279
### Using a REST Request in a Microflow {#add-entity-to-microflow}
280
280
281
-
To select a request in the microflow, complete the following steps:
281
+
To select a request in a microflow, do the following:
282
282
283
283
1. Create a new microflow and drag the [Send REST request](/refguide/send-rest-request/) activity into it.
284
284
2. Double-click the activity and click **Select** to choose the request you want to add, then click **Select** > **OK**.
If you have defined parameters in the request, they will be added to the activity. Click **Edit** to change the parameter in the microflow. The parameter values in this activity are used by the runtime instead of the test value defined in the request.
288
+
If you have defined parameters in the request, they are added to the activity. Click **Edit** to change the parameter in the microflow. The parameter values in this activity are used by the runtime instead of the test value defined in the request.
0 commit comments