How to rewrite the request url of the api using resource type in the publisher ? | Community
Skip to main content
August 18, 2023

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

  • August 18, 2023
  • 4 replies
  • 1351 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

Sudheer_Sundalam
Community Advisor
Community Advisor
August 18, 2023

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

 

thong0605Author
August 21, 2023

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

Preetpal_Bindra
Community Advisor
Community Advisor
August 18, 2023

Hello @thong0605 ,

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

 

 

thanks,

Preetpal Singh

thong0605Author
August 21, 2023

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

Rohit-Negi
Level 3
August 21, 2023

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.

 

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! 

kautuk_sahni
Community Manager
Community Manager
September 12, 2023

@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