1

I am using RapidAPI for integration of https://priceline-com-provider.p.rapidapi.com/v1/hotels/search external API with my asp.net micro-service. I need to get a JSON response from the API however it is returning gibberish data. I have tried many things to no success. enter image description here

To make sure it is good the request, I used Postman to test and it worked out fine.enter image description here

What can I do to solve this?

  • why do you need to serialize when it is already read as string and your responseValue is string type ?did you tried without calling any kind of serialization ? – CodingMytra Jun 22 '22 at 18:42

1 Answers1

0

In my case, the response was Accept-Encoding: deflate/gzip and therefore I had to insert a HttpClientHandler into the HttpClient with the correct settings:

using (var HttpClientHandler = new HttpClientHandler()
{
    AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
})
{

    using (var client = new HttpClient(HttpClientHandler))
    {
    }
}

Once I did, the await response.Content.ReadAsStringAsync() returned deserializable JSON data.

This answer led me to the solution: https://stackoverflow.com/a/69222690/2504659

01F0
  • 1,228
  • 2
  • 19
  • 32