Hi
We are trying to call the third party REST service in AEM 6.1 and following the example as per below URL.
https://helpx.adobe.com/experience-manager/using/restful-services.html
This example is working when we are creating the template and render the component that uses template. But when we are trying to create the separate component and using that component in some other template the it is not working and throwing the error like "Unable to retrieve data Bad request 400 (Bad Request)" (see the attached screenshot). Any idea what we are missing? or it will work only in case of render component that uses the template only not with separate component?
Thanks
~S
Solved! Go to Solution.
Views
Replies
Total Likes
Here is the best way to interact with a 3rd party Restful service in AEM - use HTL -- https://helpx.adobe.com/experience-manager/using/restful_htl.html
Views
Replies
Total Likes
Hi, Can you please check if OSGI bundle is in active state?
~kautuk
Views
Replies
Total Likes
Hi Kautuk,
Yes the bundle is in active states, even it is working when we are keeping the same code in render component that uses the template. it is not working when keeping it in new component and dropping the component on same template.
Thanks
~S
Views
Replies
Total Likes
In the new component, are you calling the back end the same way? It does not make sense that it works when called from a page component but not from a separate component.
Views
Replies
Total Likes
Yes Scott, we are calling exactly same way. it is very strange. when calling from separate component then only getting below attached error. You can see the attached screen shot.
GET http://localhost:4502/content/aemexample/en/restservicecomponent/_jcr_content.query.json 400 (Bad Request) granite.js:229
Thanks
~S
Views
Replies
Total Likes
I am away at Evolve AEM conference, back in Office on Fri. We can setup a connect session. We can solve this during a connect session. I want to see your code, etc.
Views
Replies
Total Likes
please find the below url ,this link may help to you
Consuming GET and POST request rest webservices in cq5:
Views
Replies
Total Likes
Yes sure Scott. we can connect on Friday. It would be great help to us.
Here is the error trace: as well.
Cannot serve request to /content/aemexample/en/testt/_jcr_content.query.json in org.apache.sling.servlets.get.DefaultGetServlet
0 TIMER_START{Request Processing} 0 COMMENT timer_end format is {<elapsed msec>,<timer name>} <optional message> 0 LOG Method=GET, PathInfo=/content/irlsoft/en/testt/_jcr_content.query.json 0 TIMER_START{ResourceResolution} 1 TIMER_END{1,ResourceResolution} URI=/content/irlsoft/en/testt/_jcr_content.query.json resolves to Resource=JcrNodeResource, type=irlsoft/components/structure/page, superType=null, path=/content/irlsoft/en/testt/jcr:content 1 LOG Resource Path Info: SlingRequestPathInfo: path='/content/irlsoft/en/testt/jcr:content', selectorString='query', extension='json', suffix='null' 1 TIMER_START{ServletResolution} 1 TIMER_START{resolveServlet(/content/irlsoft/en/testt/jcr:content)} 1 TIMER_END{0,resolveServlet(/content/irlsoft/en/testt/jcr:content)} Using servlet org.apache.sling.servlets.get.DefaultGetServlet 1 TIMER_END{0,ServletResolution} URI=/content/irlsoft/en/testt/_jcr_content.query.json handled by Servlet=org.apache.sling.servlets.get.DefaultGetServlet 1 LOG Applying Requestfilters 1 LOG Calling filter: com.adobe.granite.resourceresolverhelper.impl.ResourceResolverHelperImpl 1 LOG Calling filter: org.apache.sling.bgservlets.impl.BackgroundServletStarterFilter 1 LOG Calling filter: com.adobe.granite.rest.impl.servlet.ApiResourceFilter 1 LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter 1 LOG Calling filter: com.adobe.granite.httpcache.impl.InnerCacheFilter 1 LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter 1 LOG Calling filter: com.adobe.cq.mcm.campaign.servlets.CampaignCopyTracker 1 LOG Calling filter: com.day.cq.wcm.core.impl.WCMRequestFilter 1 LOG Calling filter: com.adobe.cq.history.impl.HistoryRequestFilter 1 LOG Calling filter: com.adobe.granite.optout.impl.OptOutFilter 1 LOG Calling filter: com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet 1 LOG Calling filter: com.adobe.cq.social.commons.cors.CORSAuthenticationFilter 1 LOG Calling filter: com.day.cq.analytics.provisioning.impl.UserAuthenticationRequestFilter 1 LOG Calling filter: org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter 1 LOG Calling filter: com.adobe.aem.irlsoft.core.filters.LoggingFilter 1 LOG Calling filter: com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter 1 LOG RedirectFilter did not redirect (not redirecting in author mode) 1 LOG Calling filter: com.day.cq.wcm.core.impl.warp.TimeWarpFilter 1 LOG Calling filter: com.day.cq.wcm.core.impl.AuthoringUIModeServiceImpl 1 LOG Calling filter: org.apache.sling.security.impl.ContentDispositionFilter 1 LOG Calling filter: com.adobe.granite.csrf.impl.CSRFFilter 1 LOG Calling filter: com.adobe.granite.requests.logging.impl.RequestLoggerImpl 1 LOG Calling filter: com.day.cq.dam.core.impl.servlet.ActivityRecordHandler 1 LOG Calling filter: com.day.cq.dam.core.impl.assetlinkshare.AdhocAssetShareAuthHandler 1 LOG Calling filter: com.adobe.cq.social.ugcbase.security.impl.SaferSlingPostServlet 1 LOG Applying Componentfilters 1 LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter 1 LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter 1 LOG Calling filter: com.day.cq.personalization.impl.TargetComponentFilter 1 TIMER_START{org.apache.sling.servlets.get.DefaultGetServlet#0} 1 LOG Using org.apache.sling.servlets.get.impl.helpers.JsonRendererServlet to render for extension=json 1 LOG Applying Error filters 1 LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter 1 LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter 1 TIMER_START{handleError:status=400} 2 TIMER_END{1,handleError:status=400} Using handler /libs/sling/servlet/errorhandler/default.jsp 5 LOG Found processor for post processing ProcessorConfiguration: {contentTypes=[text/html], order=-1, active=true, valid=true, processErrorResponse=true, pipeline=(generator=Config(type=htmlparser, config={}), transformers=(Config(type=linkchecker, config={}), Config(type=mobile, config=JcrPropertyMap [node=Node[NodeDelegate{tree=/libs/cq/config/rewriter/default/transformer-mobile: { jcr:primaryType = nt:unstructured, component-optional = true}}], values={jcr:primaryType=nt:unstructured, component-optional=true}]), Config(type=mobiledebug, config=JcrPropertyMap [node=Node[NodeDelegate{tree=/libs/cq/config/rewriter/default/transformer-mobiledebug: { jcr:primaryType = nt:unstructured, component-optional = true}}], values={jcr:primaryType=nt:unstructured, component-optional=true}]), Config(type=contentsync, config=JcrPropertyMap [node=Node[NodeDelegate{tree=/libs/cq/config/rewriter/default/transformer-contentsync: { jcr:primaryType = nt:unstructured, component-optional = true}}], values={jcr:primaryType=nt:unstructured, component-optional=true}]), serializer=Config(type=htmlwriter, config={}))} 6 TIMER_END{6,Request Processing} Dumping SlingRequestProgressTracker Entries
Views
Replies
Total Likes
Hi
I just tested the article on AEM 6.2..
Please have a look at this video.
Link:- https://kautuksahni.tinytake.com/sf/OTQzNDM2XzM5Njc1NTE
I would request you to please try this package on fresh instance.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
smacdonald2008 wrote...
I am away at Evolve AEM conference, back in Office on Fri. We can setup a connect session. We can solve this during a connect session. I want to see your code, etc.
We need to add following line in our Ajex call at /apps/restservice/components/page/templateRest/templateRest.jsp
//
$.ajax(url, {
crossDomain: true,
dataType: 'text',
Now it is is working fine.
~kautuk
Views
Replies
Total Likes
Hi Kautuk,
Thanks for troubleshooting but I just tried this also but it is not working.
It is working when we are using the same code base in to template renders component's directly.
Case 1: Working -- when keeping the code in template renders component
Case 2: Not working-- when keeping the code in to separate standalone component and dropping the component in different template page
Please have look at this video (I have captured both working and non-working cases) :
LINK:https://sameryadav.tinytake.com/sf/OTQ1NTEzXzM5NzI1NjQ
Thanks
Samer
Views
Replies
Total Likes
To reproduce it, you can follow the below steps (don't import the package as is on the helpx site):
1: Create one new separate component
2: Just copy the same code in to created component and also the query.json.jsp and clientlibs as well
3: Create one new page use any template and drop this new component from sidekick on the page.
4. Now, click on "Get Distance" button , you will see the error in to browser console as well
Thanks
~S
Views
Replies
Total Likes
Invalid recursion selector value 'query' is valid as per sling implementation. Check following for more details. http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.servlets.get-2.1.4/src/main/java/org/apa...
For custom selectors there are two approaches.
1. create a folder called query and move json.jsp into that folder. When url accessed as query.json, invalid recursion error will be thrown. To solve the issue try query.json.html
2. I prefer to go with 2nd option.
create Page.json.jsp at /apps/foundation/components/primary/cq/Page and add "<%@include file="proxy.jsp"%>". Copy proxy.jsp from /libs/foundation/components/primary/cq/Page to current folder. In proxy.jsp , implement the support for custom selector
Views
Replies
Total Likes
If you are interested in building this into an AEM component - then build a HTL (used to be Sightly) component. The Java part of the component will have a method that invokes the Restful service.
i am thinking your issue is related to calling the code via AJAX in another component. We will release this article soon that will not throw this exception when used in a HTL component.
Views
Replies
Total Likes
Here is the best way to interact with a 3rd party Restful service in AEM - use HTL -- https://helpx.adobe.com/experience-manager/using/restful_htl.html
Views
Replies
Total Likes