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

Read dam url in json format in sling servlet

Avatar

Avatar
Validate 1
Level 2
vishalv66424037
Level 2

Likes

0 likes

Total Posts

13 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 2
vishalv66424037
Level 2

Likes

0 likes

Total Posts

13 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
vishalv66424037
Level 2

02-12-2018

Hi Team,

There is requirement to read the dam url in json format inside servlet or servlce. By using Httpclient GET  getting 401 unauthorized error. Is there any way to access the same url in java ?

Thanks

Replies

Avatar

Avatar
Level 1
cq-architectl82
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
cq-architectl82
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile
cq-architectl82
Level 1

02-12-2018

you need to pass login token as header in Httpclient of get request so that your request is authenticated before content is served.

Avatar

Avatar
Validate 1
Level 2
vishalv66424037
Level 2

Likes

0 likes

Total Posts

13 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 2
vishalv66424037
Level 2

Likes

0 likes

Total Posts

13 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
vishalv66424037
Level 2

02-12-2018

Thanks for your reply.

For login token we need to pass credentials and we can't do it for the all the environments separately. Is there any other way to generate the token ?

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,430 likes

Total Posts

3,305 posts

Correct Reply

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

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,430 likes

Total Posts

3,305 posts

Correct Reply

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

02-12-2018

You may try with subservience session.

Inside your servlet or service get jcr or sling session using subservice and read dam file path.

Example:

Adobe Experience Manager Help | Querying Adobe Experience Manager 6 data using the Sling getServiceR...

Note : In Author Instance you must have to login/or access with authorised account(as mentioned in above replies) to access above.

Avatar

Avatar
Level 1
cq-architectl82
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
cq-architectl82
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile
cq-architectl82
Level 1

02-12-2018

could u please elaborate your use case in details that in which environment your servlet is running and from where you want to read dam files and whether dam files are secured files or not and if yes then what the authentication mechanism supported.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 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,409 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

02-12-2018

Do you mean you want to get URL of Assets in the DAM and encode to JSON?

Avatar

Avatar
Validate 1
Level 2
vishalv66424037
Level 2

Likes

0 likes

Total Posts

13 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 2
vishalv66424037
Level 2

Likes

0 likes

Total Posts

13 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
vishalv66424037
Level 2

03-12-2018

Need to get the response of url e.g. localhost:4502/content/dam/a/b.json and read the json.

I know using httpclient.get we need to pass the login token, my question was if there is any other way to achieve this in java. 

Thanks,

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,430 likes

Total Posts

3,305 posts

Correct Reply

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

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,430 likes

Total Posts

3,305 posts

Correct Reply

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

03-12-2018

In Author, no you can't but on publish instance you can do it without access token but you have to do it with Java to return dam path either by using queries or Asset HTTP API.

Assets HTTP API

Avatar

Avatar
Give Back
Level 1
nikhilk80697203
Level 1

Likes

2 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Boost 1
View profile

Avatar
Give Back
Level 1
nikhilk80697203
Level 1

Likes

2 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Boost 1
View profile
nikhilk80697203
Level 1

04-10-2019

Following is the solution for getting data from DAM and writing the Data.

https://aemsimplifiedbynikhil.wordpress.com/2019/10/04/read-write-data-in-json-file-of-dam-in-aem-ma...