0

I am integrating my app with a third party app and there is a requirement where I have to call their APIs. So, there is this GET call which when supplied with proper headers and params and subsequently called, returns some JSON data. Now obviously I have tried it in postman and it's working without any issues. But when I am making the same call in Java using Spring's RestTemplate (with exchange method), the JSON response I am getting is incomplete. Basically, it's giving me response like the part which is missing was never there in response. For example, In Postman, the response looks like this:

{
       "key1": object 1,
       "key2": object 2
 }

But in Java, the response looks like this:

{
       "key1": object1
 }

The response is incomplete. Also, after doing some analysis I have found that there is this response header: content-length, it's value in Postman is 933 and in Java it's 840. What can be done to solve this problem?

redHalo
  • 123
  • 2
  • 7
  • Your requests almost certainly aren't identical, since the server is changing behavior (by explicitly returning different content). – chrylis -cautiouslyoptimistic- Jul 31 '20 at 18:51
  • @chrylis It's not different. It's the same content. But without the missing part. Also, I did confirm with the API people whether there was any case where the response could be this, but it turns out there isn't. – redHalo Jul 31 '20 at 18:55
  • If it has a "missing part", then _by definition it's not the same_. Furthermore, the `Content-Length` is clearly stating that the server is returning different content. Something different in your request might be triggering the different behavior, but the server _is_ sending different content, regardless of what "the API people" believe. – chrylis -cautiouslyoptimistic- Jul 31 '20 at 19:30

0 Answers0