I cannot figure out how to remove whitespaces from the start and end of my strings.
My response body is:
{
"value": [
{
"nomeUnidadeOperacional": " ",
"nomeCaixaPostalComunitaria": " ",
"nroCaixaPostal": " ",
"enderecoCaixapostal": " "
}
]
}
I tried using "| split" and "{%- assign item = body.value[0] -%}" as the documentation for liquid explain "whitespace control".
My set-body:
<set-body template="liquid">
{
"Endereco": {
{% assign item = body.value[0] %}
"caixaPostal": {
"nome": "{{item.nomeCaixaPostalComunitaria | strip }}",
"numero": "{{item.nroCaixaPostal | strip }}",
"endereco": "{{item.enderecoCaixapostal | strip }}"
}
}
}
</set-body>
What I'm getting:
{
"Endereco": {
"caixaPostal": {
"nome": " ",
"numero": " ",
"endereco": " "
}
}
}
What I expected:
{
"Endereco": {
"caixaPostal": {
"nome": "",
"numero": "",
"endereco": ""
}
}
}
Sure i could use a if to test if the content is " " and replace it after, but i could have more than 1 whitespace and this option isn't elegant.
On API Management you need to write the Filter Capitalized.
"nome": "{{item.nomeCaixaPostalComunitaria | Strip }}",