Question 131 of 179 from exam AZ-204: Developing Solutions for Microsoft Azure

Question 131 of 179 from exam AZ-204: Developing Solutions for Microsoft Azure

Question

DRAG DROP - You are developing a REST web service.

Customers will access the service by using an Azure API Management instance.

The web service does not correctly handle conflicts.

Instead of returning an HTTP status code of 409, the service returns a status code of 500

The body of the status message contains only the word conflict.

You need to ensure that conflicts produce the correct response.

How should you complete the policy? To answer, drag the appropriate code segments to the correct locations.

Each code segment may be used once, more than once, or not at all.

You may need to drag the split bar between panes or scroll to view content.

NOTE: Each correct selection is worth one point.

Select and Place:

Policy segments Answer Area

Senet <| Policysegment | >
context <base />
<choose>
on-error <when condition = “@| Policysegment |.Response.StatusCode == 500
aR [Policy segment | .LastError.Message.Contains
set-status ( “conflict =" )) ">
<return-response>
when-error < | Policysegment | >
</return-response>
override-status </when>
<otherwise />
</choose>

<| Policysegment | >

Explanations

Policy segments

server

context

on-error

set-status

when-error

override-status

Answer Area

< jon-error >

<base />
<choose>

<when condition = ”

B&

context

<return-response>

context

< |set-status

</return-response>

</when>

<otherwise />

</choose>

< jon-error >

-LastError.Message. Contains

(

Response. StatusCode == 500

" conflict

=e

Box 1: on-error - Policies in Azure API Management are divided into inbound, backend, outbound, and on-error.

If there is no on-error section, callers will receive 400 or 500 HTTP response messages if an error condition occurs.

Box 2: context - Box 3: context - Box 4: set-status - The return-response policy aborts pipeline execution and returns either a default or custom response to the caller.

Default response is 200 OK with no body.

Custom response can be specified via a context variable or policy statements.

Syntax: &amp;lt;return-response response-variable-name="existing context variable"&amp;gt; &amp;lt;set-header/&amp;gt; &amp;lt;set-body/&amp;gt; &amp;lt;set-status/&amp;gt; &amp;lt;/return-response&amp;gt; Box 5: on-error - Reference: https://docs.microsoft.com/en-us/azure/api-management/api-management-error-handling-policies https://docs.microsoft.com/en-us/azure/api-management/api-management-transformation-policies.