A common cause of confusion, especially for newly hatched developers, is the one-lettered distinction between URL and URI.
In the world of Mulesoft the term used to designate URL parameters, also known as URL query strings, is QueryParams. URL stands for Uniform Resource Locator. It contains information about a resource's location and may refer to a web page, a downloadable file, an e-mail address, etc.
QueryParams are a part of the URL. Their start within a URL is denoted by the question mark. Different QueryParams are separated by the ampersand (&) sign. QueryParams always come in key-value pairs.
URI, which stands for Uniform Resource Identifier, is a set of characters (a short string) used to identify a resource. In theory and on paper many things can be considered a resource, but for all practical purposes within the Mulesoft context, a URI identifies something unique by its name or value at a specified location in the URL.
A URI is a part of a URL but, unlike URL parameters or QueryParams, a URI parameter does not appear as a key-value pair in a URL and cannot be recognized instantly. At the first glance, URI parameters within URLs look like a file path of folders and subfolders separated by a slash. This is because only the value part is show in in the URL.
QueryParams are specified in the URL. An HTTP Listener in a Mule application will recognize and save them as attributes in the Mule message. Since URI parameters do not appear as key-value pairs in the URL, the key part as well as the URI parameter location within the URL must be specified in advance in the corresponding RAML file.
Then, after an HTTP Request is sent by a web client, the value will be assigned to the key, according to the RAML specification. The value can be accessed in Anypoint Studio through the attributes.
DataWeave expression
Use this DataWeave expression to retrieve values saved as attributes in the Mule 4 message:
#[attributes.queryParams.country]
#[attributes.uriParams.country]
RELATED ARTICLES
OTHER ARTICLES
OLDER ARTICLES
LATEST FORUM UPDATES
APIAmeeth, Thursday, 1.9.2022 / 21:23
Jay-Catalyst, Tuesday, 2.11.2021 / 10:48
Matteo, Friday, 3.7.2020 / 16:30
Matteo, Friday, 3.7.2020 / 16:29
Matteo, Friday, 3.7.2020 / 16:28
Caio S Cavalcante, Friday, 22.5.2020 / 16:59
Edo Schatz, Thursday, 21.5.2020 / 13:50
Edo Schatz, Thursday, 21.5.2020 / 11:29
Edo Schatz, Wednesday, 20.5.2020 / 18:18
Edo Schatz, Monday, 18.5.2020 / 16:33
NEW ARTICLES
POPULAR ARTICLES