Response Body Transform


#1

I have an API which just returns one parameter in the response payload.
Current Behavior (response):
{
“token”: “Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRfaWQiOiIzMWY4MzU2MS1jMGQzLTRlOTItODVhYy0yMjRmODc3MWY1MzgiLCJjbGllbnRfcGFzc3dvcmQiOiI1U0F0Uzg5Um52WnRLSDV6IiwiaWF0IjoxNTUzMTU0MDgyLCJleHAiOjE1NTMxNTc2ODJ9.NHo1DqYqfKO58E1nk5LqMMU81c0tMTpVdx0b6D7FKz0”
}

However, I have to transform the response payload to pass the parameter inside a data tag. I have added the response body transform in the endpoint designer; but cant seem to get the response in the desired format.
Expected response:
{
“data”: {
“token”: “Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRfaWQiOiIzMWY4MzU2MS1jMGQzLTRlOTItODVhYy0yMjRmODc3MWY1MzgiLCJjbGllbnRfcGFzc3dvcmQiOiI1U0F0Uzg5Um52WnRLSDV6IiwiaWF0IjoxNTUzMTU0MDgyLCJleHAiOjE1NTMxNTc2ODJ9.NHo1DqYqfKO58E1nk5LqMMU81c0tMTpVdx0b6D7FKz0”
}
}

I have tested the following template and it works in the endpoint designer. But I dont get the correct response:
Template:
{
“data”: {
“token”: “{{.token}}”
}
}

Any idea what I am missing?


#2

Hi,
What response do you see in your requests? Do you have any other middleware running in that endpoint?

Thanks