Expand my Community achievements bar.

How to rewrite the request url of the api using resource type in the publisher ?

Avatar

Level 1

Hello everyone,

I have an api using Sling Resource Type that return the response in XML format.
I can call the API with the author IP and return the response in XML format:
For example url :
- {{ author IP }}/content/projectName/en/pageName/optionalSubPageName.selector.xml?param=abc


It returned the response in XML format
==> CORRECT as expected.

However, when I call the api with the PUBLISH IP OR PUBLISH DOMAIN such as:
- {{ publish IP }}/content/projectName/en/pageName/optionalSubPageName.selector.xml?param=abc
- {{ publish domain }}/pageName/optionalSubPageName.selector.xml?param=abc

It will automatically direct to the PAGE at the path "pageName" or "optionalSubPageName" instead of the response XML format.

Note: the {{ publish IP }} will automatically rewritten to {{ publish domain }} when it was called.

==> NOT CORRECT as expected.

My expectation: I can call the api and return the response in XML format with the request url as:
- {{ publish domain }}/pageName/optionalSubPageName.selector.xml?param=abc

Do you have any suggestion or is there any solution for this one ?
I don't have much experience with this situation.

P/s: the project is running by AEM CLOUD Service and on Adobe server. So it seems I cannot visit /system/console page.

Thank you in advance.

6 Replies

Avatar

Community Advisor

@thong0605 ,

On the publish server, GoTo publishserver:4503/system/console/configMgr and search for "Apache Sling GET Servlet" configuration. Open the configuration and check the "Enable XML" checkbox and save the configuration.

 

Try this option and see if it works for you.

Sudheer_Sundalam1_0-1692368680924.png

 

Avatar

Level 1

Hi @Sudheer_Sundalam,
Thanks for your response,
Sorry I've forgot to mention that my project is running by AEM CLOUD Service and on Adobe server. So it seems I cannot visit /system/console page.

Btw I'll try to enable that configuration via code deploying.
FYI

Avatar

Community Advisor

Hello @thong0605 ,

When you paste the publisher URL into the Configuration Test text box in this screen, what does it show?

 

PreetpalSinghBi_1-1692389463229.png

 

thanks,

Preetpal Singh

Avatar

Level 1

Hi @Preetpal_Bindra,
Thanks for your response,
Sorry I've forgot to mention that my project is running by AEM CLOUD Service and on Adobe server. So it seems I cannot visit /system/console page.

If you have been working on AEM CLOUD service, do you have any suggestion ?
FYI

Avatar

Level 4

You can download all the configuration from Cloud-Manager that are visible in system/console and can check the relevant information.

Go to the CloudManager and then to the developer console. From developer console download the configuration. If you dnt have access, some one from your team should be having.

Rohit_Negi550_0-1692601657389.png

 

Create a new configuration for Apache Sling Servlet using the pID and set the XML checkbox to true.

Once done, deploy your code and check if that helps.

 

Thanks! 

Avatar

Administrator

@thong0605 Do you find the suggestions from users useful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. 



Kautuk Sahni