While trying to login to AEM using POST having request body, the resource recognizes it as a GET and does not give the request body

Avatar

Avatar

jebs89

Avatar

jebs89

jebs89

23-08-2018

http://localhost:4502/ecat/j_security_check?j_username=abc&j_password=abc&resource=/ecat/apps/cat/in... is the POST URL used to login to our application and land on the servlet path /ecat/apps/cat/injectorwebhook. It has a request body containing a json snippet. When i do a request.getMethod() in the servlet i get it as a GET and could not have a hold on the json from the request body. Why is it treated as a GET method? how to retrieve the body json from the request?

Replies

Avatar

Avatar

jebs89

Avatar

jebs89

jebs89

23-08-2018

i use a URL http://admin:admin@localhost:4502/ecat/apps/cat/injectorwebhook. This takes me to the servlet and is treated as a POST and all is good.


Logs:

inside MerlionWebhookServlet dopost

Method: POST

jsonRequestText : {

  "fragments": {

    "DDD001017_id06": {

      "targetLangs": ["es_XC", "zh_XC"]

    },

    "EEE001018_id01": {

      "targetLangs": ["fr_FR"]

    }

  }

}

But due to dependent system behavior i cannot use this URL. What is the difference in behavior between these two URLs?

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.0K

Likes

1.1K

Correct Reply

861

Avatar

Arun_Patidar

MVP

Total Posts

3.0K

Likes

1.1K

Correct Reply

861
Arun_Patidar
MVP

24-08-2018

Hi,

If you directly hit the URL in the browser, it will. be treated as GET request. To make POST request either submit form  or call url via ajax using post method.

Screen Shot 2018-08-24 at 9.06.16 AM.png

Screen Shot 2018-08-24 at 9.19.05 AM.png

Avatar

Avatar

jebs89

Avatar

jebs89

jebs89

24-08-2018

I use POSTMAN to send a POST call attaching the request body in it.

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.0K

Likes

1.1K

Correct Reply

861

Avatar

Arun_Patidar

MVP

Total Posts

3.0K

Likes

1.1K

Correct Reply

861
Arun_Patidar
MVP

24-08-2018

Hi,

In above screenshot you can see, I made the post request for same code using AJAX. If I hit same page directly with browser I am getting GET.

So the real issue is the way you are making call to your servlet.

Avatar

Avatar

Albin_Issac

MVP

Avatar

Albin_Issac

MVP

Albin_Issac
MVP

24-08-2018

My perspective you should be invoking the servlet URL directly with POST method and set the authentication header as part of the request.

e.g Authorization Basic YWRtaW46YWRtaW4=

Encode the following string username:password(e.g admin:admin)

Regards

Albin I

www.albinsblog.com

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

996

Correct Reply

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

996

Correct Reply

1.0K
Jörg_Hoh
Employee

24-08-2018

Please find this request in the server logs; in the request log you should find this request and it will clearly identify what method was used.

Jörg