A web service implements an API to handle requests to http://acme.com/customers/{state}. A web client makes a request to http://acme.com/customers/CA. What is the correct MEL expression to retrieve the value CA?

Study for the MuleSoft Associate / Development Fundamental Test. Master key concepts with flashcards and multiple choice questions, complete with hints and explanations. Prepare thoroughly for your exam!

Multiple Choice

A web service implements an API to handle requests to http://acme.com/customers/{state}. A web client makes a request to http://acme.com/customers/CA. What is the correct MEL expression to retrieve the value CA?

Explanation:
When a REST endpoint defines a path parameter, the value is captured in the HTTP inbound properties under http.uri.params and can be read in MEL by accessing that map with the parameter’s name. For the request to /customers/CA, the path parameter is state, so you retrieve it with message.inboundProperties.'http.uri.params'.state. The expression #[message.inboundProperties.'http.uri.params'.state] picks up the value of the state parameter from the HTTP request, which is CA in this case. Other options don’t access the path parameter correctly: one looks at the payload, another uses a different parameter name (city), and the last tries to read a literal property named CA, which isn’t how path parameters are exposed.

When a REST endpoint defines a path parameter, the value is captured in the HTTP inbound properties under http.uri.params and can be read in MEL by accessing that map with the parameter’s name. For the request to /customers/CA, the path parameter is state, so you retrieve it with message.inboundProperties.'http.uri.params'.state.

The expression #[message.inboundProperties.'http.uri.params'.state] picks up the value of the state parameter from the HTTP request, which is CA in this case. Other options don’t access the path parameter correctly: one looks at the payload, another uses a different parameter name (city), and the last tries to read a literal property named CA, which isn’t how path parameters are exposed.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy