AEMasCS - Programmatically interact with AEM Author services over HTTP using Service Credentials | Community
Skip to main content
Level 2
November 23, 2023
Solved

AEMasCS - Programmatically interact with AEM Author services over HTTP using Service Credentials

  • November 23, 2023
  • 3 replies
  • 1631 views

Hi,

I am working on a requirement that to upload the images to AEM author environment from an external application. To achieve this requirement, followed the below steps.

  •  Generated service credentials associated with the technical account.
  • Using service credentials, created the access token that can be used to access AEM as CS.

I am running the java code inside corporate machine.
When I try to make HTTP connection to AEM using the access token(bearer token), I am getting below error

java.net.UnknownHostException: No such host is known (author-p123456-e123107.adobeaemcloud.com)

at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)

at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)

at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:933)

at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1534)

at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:852)

at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1524)

at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1381)

at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1305)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:112)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:221)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)

at aem.sdk.api@2021.6.5540.20210615T210737Z-210527/org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140)

at uploadassets/com.adobe4.HttpPostRequestMethodExample.postUser(HttpPostRequestMethodExample.java:46)

at uploadassets/com.adobe4.HttpPostRequestMethodExample.main(HttpPostRequestMethodExample.java:26)

 

Please help me resolve this error.  Thanks!

Source code: I am using the same script as mentioned in the below blog.

https://experience-aem.blogspot.com/2021/06/aem-cloud-service-sample-java-standalone-program-upload-assets.html


Reference:

https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/authentication/service-credentials.html?lang=en 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by A_H_M_Imrul

@kamsdurai 

Yes, it was expected. 

To be able to run the upload program successfully, you need to be able to connect to the host (from this machine). So now two options I can see:

1. talk to your IT admin and get this connection established (as the host is already available on the internet)

2. you can run the program from another network or machine, where there is no such network constraint (if possible)

Let me know for further help.

 

3 replies

A_H_M_Imrul
Community Advisor
Community Advisor
November 23, 2023

@kamsdurai 

The hostname seems available on the internet, but can you please check if you can ping the server from your corporate machine?

let me know your findings.

 

 

kamsduraiAuthor
Level 2
November 23, 2023

seems like I am not able to ping the server.

A_H_M_Imrul
Community Advisor
A_H_M_ImrulCommunity AdvisorAccepted solution
Community Advisor
November 23, 2023

@kamsdurai 

Yes, it was expected. 

To be able to run the upload program successfully, you need to be able to connect to the host (from this machine). So now two options I can see:

1. talk to your IT admin and get this connection established (as the host is already available on the internet)

2. you can run the program from another network or machine, where there is no such network constraint (if possible)

Let me know for further help.

 

Harwinder-singh
Community Advisor
Community Advisor
November 23, 2023

@kamsdurai You need to get the IP of your AEM instance whitelisted so that you can access it from where you are initiating this request. It should work once that is done. 

kautuk_sahni
Community Manager
Community Manager
November 28, 2023

@kamsdurai Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni