0

I'm using RESTassured with Java. Getting response in compressed from UTF16 format. Response varies from developer tool to code debugging in Chrome/Firefox, here variation means some character got changed.

Steps:

  1. Loaded the URL
  2. Opened developer tool by pressing F12
  3. Selected the API and checked the response. Here i got response like: ᯡࡈ䆼̀䬥堰攢䰢\ᙴঠ㙀ழⓒ
  4. Then gone to sources then checked the response it was something like this ᯡࡈ䆼̀䬥堰攢䰢ᙴঠ㙀ழⓒ

How to handle this? what all the response contains? is it contains headers?

3 Answers 3

2

What you show is actually a response body. Headers are represented in "Headers" tab in Dev Tools like this:

enter image description here

Brief look up of what you provided shows that it's UTF-16 encoded string:

enter image description here

For example:

1 - BATAK LETTER CA

2 - MANDAIC LETTER ATT

3 - http://www.fileformat.info/info/unicode/char/41bc/browsertest.htm no dedicated name

0

I guess the trivial way to handle this is convert the charset to unicode and verify. Java String supports unicode by-default.

The below article states how to convert to and from unicode charset: http://tutorials.jenkov.com/java-internationalization/unicode.html

Coming to the second part of the question. Below are the major part of an HTTP Response.

  • Status
  • Response Header
  • Response Fields

Below is the link which details out http Response:

https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html

0

Resolved this issue by following:

String x=respe.asString();
        JSONParser par = new JSONParser(); 
        String  st = (String) par.parse(x);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.