AEMasCS - Programmatically interact with AEM Author services over HTTP using Service Credentials
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.
Reference: