Hi Experts,
We are creating Adobe Experience Manager bundles that invoke third party Restful web services.
To create the AEM client that displays data returned by the Restful service, created these files:
Now, When trying to excute it then it is throwing the BAD Request. Do we need to do any configuration for it?
GET http://localhost:4502/content/aemexample/en/restwebservicetest/_jcr_content.query.json
Attached screen of errors
Thanks
~S
Solved! Go to Solution.
Views
Replies
Total Likes
Did you see our example that successfully invokes a Google Restful Service.
try
{
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet getRequest = new HttpGet("http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver%20BC&destinations=San%20Fr...");
getRequest.addHeader("accept", "application/json");
HttpResponse response = httpClient.execute(getRequest);
if (response.getStatusLine().getStatusCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatusLine().getStatusCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
String output;
String myJSON="" ;
while ((output = br.readLine()) != null) {
//System.out.println(output);
myJSON = myJSON + output;
}
httpClient.getConnectionManager().shutdown();
return myJSON ;
}
It uses Java HTTP API within a bundle and then displays the results in a JSP. (we will update this at some point to show usage within SIghtly).
https://helpx.adobe.com/experience-manager/using/restful-services.html
You can install the package and invoke it to see the result.
Views
Replies
Total Likes
Did you see our example that successfully invokes a Google Restful Service.
try
{
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet getRequest = new HttpGet("http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver%20BC&destinations=San%20Fr...");
getRequest.addHeader("accept", "application/json");
HttpResponse response = httpClient.execute(getRequest);
if (response.getStatusLine().getStatusCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatusLine().getStatusCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
String output;
String myJSON="" ;
while ((output = br.readLine()) != null) {
//System.out.println(output);
myJSON = myJSON + output;
}
httpClient.getConnectionManager().shutdown();
return myJSON ;
}
It uses Java HTTP API within a bundle and then displays the results in a JSP. (we will update this at some point to show usage within SIghtly).
https://helpx.adobe.com/experience-manager/using/restful-services.html
You can install the package and invoke it to see the result.
Views
Replies
Total Likes
I just tested on AEM 6.1 - it works:
Install the package and run it. It works.
If you have issues - we can setup a connect session.
Views
Replies
Total Likes
Yes Actually I am following that example. When I downloaded the packages and installed then it is working fine. However when created the same bundle by using the maven eclipse and installed it. but when hitting the url then it is throwing the error like bad request. I don't know What I am missing.
Thanks
~S
Views
Replies
Total Likes
Compare your project with the package project - it could be anything such as the JSPs are not at the same node level as the main component JSP or a copy and paste error was made. This is exactly why we package up the HELPX articles so community members can run them and compare to their projects if they follow along. Most of the time - its a minor error.
Views
Replies
Total Likes
Views
Replies
Total Likes
Yes - we will hold it weds mar 2.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies