Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

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

Avatar

Level 2

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-...


Reference:

https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/a... 

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@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.

 

View solution in original post

5 Replies

Avatar

Community Advisor

@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.

 

 

Avatar

Correct answer by
Community Advisor

@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.

 

Avatar

Community Advisor

@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. 

Avatar

Administrator

@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