Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
34.29k stars 1.92k forks source link

Preview Mode: Visual Preview / Source Code outputting [] instead of JSON response #2968

Open soubhikchatterjee opened 3 years ago

soubhikchatterjee commented 3 years ago

Describe the bug I am testing my Rest APIs that sends back a JSON response. "Visual Preview" and "Source Code" shows [] as the response, white the "Raw Data" option shows the proper JSON response. If i hit the same API using Postman, the formatting shows properly. I am sharing the screencast of both Insomnia and Postman, may be this will help you get an idea of what is this happening. Also, attaching the header information so that you may know why is this happening.

Expected behavior JSON response should show in a formatted manner.

Screenshots Insomnia: https://share.getcloudapp.com/Z4uqnzex

Postman: https://share.getcloudapp.com/llun7wmY

Headers: https://share.getcloudapp.com/12uK7E9L

Desktop (please complete the following information):

Additional context Version: Insomnia Core 2020.5.2 Release date: 09/12/2020 OS: Darwin x64 18.7.0 Electron: 9.1.1 Node: 12.14.1 V8: 8.3.110.13-electron.0 Architecture: x64 node-libcurl: libcurl/7.69.1 OpenSSL/1.1.1g zlib/1.2.11 brotli/1.0.7 libidn2/2.1.1 libssh2/1.9.0 nghttp2/1.41.0

nijikokun commented 3 years ago

What is the mimetype for the response?

soubhikchatterjee commented 3 years ago

Not sure where to look for the mimetype, but as per the header screenshot above, the response content type is application/json

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jeremycook commented 3 years ago

I ran into a similar situation but it turned out that I had applied a JSONPath filter and forgot about it, and once I cleared the JSONPath filter the data showed up in Preview and Source Code views like expected. The JSONPath was an array filter that became invalid after the shape of the root element changed from an array to an object.

I think a take away from my experience is that it isn't very obvious when a JSONPath filter is being applied. The text of the JSONPath filter is too faded out when you enter something and it just isn't obvious that you are filtering. I think that making it more obvious would help avoid this.