Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue on Response Templating #142

Open
Alisha-Zaara opened this issue Aug 23, 2023 · 0 comments
Open

Issue on Response Templating #142

Alisha-Zaara opened this issue Aug 23, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Alisha-Zaara
Copy link

Page

/docs/response-templating/

Details

I am using gradle dependency: implementation 'com.github.tomakehurst:wiremock:2.27.2'

My JSON stub mapping is calling a POST URL using proxyBaseUrl and sending the response to transformers (I am writing my own transformer class by extending ResponseTransformer to dynamically change the response based on the response from proxy URL).
JSON Stub:
image

Issue:

  1. I can see the response from proxyBaseUrl as HTTP 200, but when I try printing the body using response.getBodyAsString(), it returns a string in unreadable format.
    200 response: image

response.getBodyAsString():

image

How can I read this response in readable format (preferably json), to change the response dynamically using transformer functionality.

  1. response.getBody() method returns a byte array.

response.getBody():
image

Tried decoding the byte array returned using all StandardCharsets and
new String(response.getBody(), response.getHeaders().getContentTypeHeader().charset());

image

How can I convert this byte array in a readable format. Thank you in anticipation of a solution.

Suggested Edits

No response

References

No response

@Alisha-Zaara Alisha-Zaara added the bug Something isn't working label Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant