Score:1

cURL on Ubuntu 21.04 does not usually display JSON response bodies

cn flag

I just installed Ubuntu 21.04. I was surprised to find that the version of curl that comes installed does not display JSON response bodies in many cases... I'm still trying to understand why sometimes JSON bodies are shown and other times they aren't. In some cases adding -H "Accept: application/json" to the calls does display the body, but I've never needed to specify that before.

Unfortunately, the APIs I discovered this with are company-internal so I can't post the specific example, but I will say they are APIs hosted on AWS ApiGateway in case that's helpful. GET response bodies are JSON, and display fine on both Debian and macOS.

  • The version of curl on my Ubuntu computer is 7.74
  • The version on my work computer (macOS) is 7.64
  • running curl -v https://api.company.com/dev/endpoint on my Ubuntu machine and work MacBook produce nearly identical outputs ending with
    * Connection #0 to host api.company.com left intact
    on both machines, but on macOS there's an additional line containing the body
    {"internal_code": "ok", ....}* Closing connection 0

Finally, I'll add that...

  • the JSON response body of curl https://reqbin.com/echo/get/json does display on Ubuntu, and sometimes the bodies from the internal API display if I add -H "Accept: application/json" to the curl (but not always).
  • HTML response bodies seem to show always.
northernwind avatar
co flag
I have same on windows 10 machine. The `-H` header does not help
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.