Skip to content

Commit 9595f7a

Browse files
committed
(#70654) Correcting language from GitHub issue
1 parent 7d8fcc1 commit 9595f7a

File tree

1 file changed

+41
-43
lines changed

1 file changed

+41
-43
lines changed

articles/api-management/api-management-sample-send-request.md

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,10 @@ Once you have this information, you can make requests to all the backend systems
208208
</send-request>
209209
```
210210

211-
These requests execute in sequence, which is not ideal.
211+
API Management will send these requests sequentially.
212212

213213
### Responding
214+
214215
To construct the composite response, you can use the [return-response](./api-management-advanced-policies.md#ReturnResponse) policy. The `set-body` element can use an expression to construct a new `JObject` with all the component representations embedded as properties.
215216

216217
```xml
@@ -233,55 +234,52 @@ The complete policy looks as follows:
233234

234235
```xml
235236
<policies>
236-
<inbound>
237-
238-
<set-variable name="fromDate" value="@(context.Request.Url.Query["fromDate"].Last())">
239-
<set-variable name="toDate" value="@(context.Request.Url.Query["toDate"].Last())">
240-
241-
<send-request mode="new" response-variable-name="revenuedata" timeout="20" ignore-error="true">
242-
<set-url>@($"https://accounting.acme.com/salesdata?from={(string)context.Variables["fromDate"]}&to={(string)context.Variables["fromDate"]}")"</set-url>
243-
<set-method>GET</set-method>
244-
</send-request>
245-
246-
<send-request mode="new" response-variable-name="materialdata" timeout="20" ignore-error="true">
247-
<set-url>@($"https://inventory.acme.com/materiallevels?from={(string)context.Variables["fromDate"]}&to={(string)context.Variables["fromDate"]}")"</set-url>
248-
<set-method>GET</set-method>
249-
</send-request>
250-
251-
<send-request mode="new" response-variable-name="throughputdata" timeout="20" ignore-error="true">
252-
<set-url>@($"https://production.acme.com/throughput?from={(string)context.Variables["fromDate"]}&to={(string)context.Variables["fromDate"]}")"</set-url>
253-
<set-method>GET</set-method>
254-
</send-request>
255-
256-
<send-request mode="new" response-variable-name="accidentdata" timeout="20" ignore-error="true">
257-
<set-url>@($"https://production.acme.com/accidentdata?from={(string)context.Variables["fromDate"]}&to={(string)context.Variables["fromDate"]}")"</set-url>
258-
<set-method>GET</set-method>
259-
</send-request>
260-
261-
<return-response response-variable-name="existing response variable">
262-
<set-status code="200" reason="OK" />
263-
<set-header name="Content-Type" exists-action="override">
264-
<value>application/json</value>
265-
</set-header>
266-
<set-body>
267-
@(new JObject(new JProperty("revenuedata",((IResponse)context.Variables["revenuedata"]).Body.As<JObject>()),
268-
new JProperty("materialdata",((IResponse)context.Variables["materialdata"]).Body.As<JObject>()),
269-
new JProperty("throughputdata",((IResponse)context.Variables["throughputdata"]).Body.As<JObject>()),
270-
new JProperty("accidentdata",((IResponse)context.Variables["accidentdata"]).Body.As<JObject>())
271-
).ToString())
272-
</set-body>
273-
</return-response>
237+
<inbound>
238+
<set-variable name="fromDate" value="@(context.Request.Url.Query["fromDate"].Last())">
239+
<set-variable name="toDate" value="@(context.Request.Url.Query["toDate"].Last())">
240+
241+
<send-request mode="new" response-variable-name="revenuedata" timeout="20" ignore-error="true">
242+
<set-url>@($"https://accounting.acme.com/salesdata?from={(string)context.Variables["fromDate"]}&to={(string)context.Variables["fromDate"]}")"</set-url>
243+
<set-method>GET</set-method>
244+
</send-request>
245+
246+
<send-request mode="new" response-variable-name="materialdata" timeout="20" ignore-error="true">
247+
<set-url>@($"https://inventory.acme.com/materiallevels?from={(string)context.Variables["fromDate"]}&to={(string)context.Variables["fromDate"]}")"</set-url>
248+
<set-method>GET</set-method>
249+
</send-request>
250+
251+
<send-request mode="new" response-variable-name="throughputdata" timeout="20" ignore-error="true">
252+
<set-url>@($"https://production.acme.com/throughput?from={(string)context.Variables["fromDate"]}&to={(string)context.Variables["fromDate"]}")"</set-url>
253+
<set-method>GET</set-method>
254+
</send-request>
255+
256+
<send-request mode="new" response-variable-name="accidentdata" timeout="20" ignore-error="true">
257+
<set-url>@($"https://production.acme.com/accidentdata?from={(string)context.Variables["fromDate"]}&to={(string)context.Variables["fromDate"]}")"</set-url>
258+
<set-method>GET</set-method>
259+
</send-request>
260+
261+
<return-response response-variable-name="existing response variable">
262+
<set-status code="200" reason="OK" />
263+
<set-header name="Content-Type" exists-action="override">
264+
<value>application/json</value>
265+
</set-header>
266+
<set-body>
267+
@(new JObject(new JProperty("revenuedata",((IResponse)context.Variables["revenuedata"]).Body.As<JObject>()),
268+
new JProperty("materialdata",((IResponse)context.Variables["materialdata"]).Body.As<JObject>()),
269+
new JProperty("throughputdata",((IResponse)context.Variables["throughputdata"]).Body.As<JObject>()),
270+
new JProperty("accidentdata",((IResponse)context.Variables["accidentdata"]).Body.As<JObject>())
271+
).ToString())
272+
</set-body>
273+
</return-response>
274274
</inbound>
275275
<backend>
276-
<base />
276+
<base />
277277
</backend>
278278
<outbound>
279-
<base />
279+
<base />
280280
</outbound>
281281
</policies>
282282
```
283283

284-
In the configuration of the placeholder operation, you can configure the dashboard resource to be cached for at least an hour.
285-
286284
## Summary
287285
Azure API Management service provides flexible policies that can be selectively applied to HTTP traffic and enables composition of backend services. Whether you want to enhance your API gateway with alerting functions, verification, validation capabilities or create new composite resources based on multiple backend services, the `send-request` and related policies open a world of possibilities.

0 commit comments

Comments
 (0)