Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

API call response - JSON downlading

Avatar

Avatar
Validate 1
Level 2
Tanmay137
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
Tanmay137
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
Tanmay137
Level 2

21-02-2019

Hello everyone,

We have an API service, when I use it to get a JSON response in the browser. The file is downloading instead of displaying in browser?

It is happening on only localhost and Publish environment. It works perfectly on Author.

Is there any configuration settings I need to change to restrict the JSON from being downloading?

Thanks

Tanmay

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,279 likes

Total Posts

3,155 posts

Correct Reply

889 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,279 likes

Total Posts

3,155 posts

Correct Reply

889 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

21-02-2019

Hi,

Please make sure when your API returns response, it should set below response header in order to display JSON

Content-Type: application/json; charset=UTF-8

Answers (5)

Answers (5)

Avatar

Avatar
Validate 1
Level 2
Tanmay137
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
Tanmay137
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
Tanmay137
Level 2

21-02-2019

It worked, Thank you Arun.

Avatar

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
Gaurav-Behl
MVP

21-02-2019

Content-Disposition - HTTP | MDN  says  In a regular HTTP response, the Content-Disposition response header is a header indicating if the content is expected to be displayed inline in the browser, that is, as a Web page or as part of a Web page, or as an attachment, that is downloaded and saved locally.

Hence, check the request headers and also check Apache Sling Content Disposition Filter configuration in /system/console/configMgr or it could be somewhere in your code or specific browser behavior.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

21-02-2019

See Arun suggestion.

Also - in a use case we have in an article,  - we make a call to a service that returns JSON. We then parse the JSON and set our Java's data members and then display the data in a HTL component's view. At no point - is the JSON downloaded. See:

Creating an Adobe Experience Manager 6.4 HTL Component that displays data from a Restful Web Service 

Avatar

Avatar
Validate 1
Level 2
Tanmay137
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
Tanmay137
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
Tanmay137
Level 2

21-02-2019

Thank for your quick response.

We are writing a servlet and exposing the endpoints. It a custom service created using Java and yes, are are parsing the JSON.

To add further to my question, we get a response when I hit the endpoint Author URL, when I try to hit the same using postman, we don't get any response.

Publish and Localhost URL just download the JSON file.

Thank you

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

21-02-2019

In your AEM Service - how are you getting the JSON - are you calling another service that returns JSON. Are you then parsing the JSON? Is this a custom service that you created using Java?