Not able to call rest service in postman due to 401 error

I have installed version 6.0.3. When I am accessing localhost:8080/login.jsp, regardless of right/wrong password, always login page is getting retured.

I have used following option
Basic Auth: admin/admin

header: X-Requested-With=XMLHttpRequest
Content-Type = application/json

Body: {
« username »: « admin »,
« password » : « admin »
}

Also it provides cookie:
JSESSIONID=D1C36B38DC0862C05F49CF91E1142B00; Path=/; Domain=localhost; HttpOnly;

But when I am trying to access any other WS with same cookie, then I receive HTTP Status 401 – Unauthorized

http://localhost:8080/ws/meta/models

I also tried with Basic Auth: admin/admin

Also, I do not see any file where I can enable basic auth: axelor-source\axelor-erp\modules\axelor-open-suite

Please help

#!/bin/bash
curl -c cookies.txt --location --request POST ‹ http://localhost/login.jsp › --header ‹ Content-Type: application/json › --data-raw ‹ {
« username »: « admin »,
« password »: « admin »
} ›
curl -b cookies.txt --location --request POST ‹ http://localhost/ws/action › --header ‹ Content-Type: application/json › --data-raw ‹ {« model »:« com.axelor.meta.db.MetaView »,« action »:« action-meta-restore-all »,« data »:{"_domain":null,"_domainContext":{"_id":null,"_model":« com.axelor.meta.db.MetaView »},« operator »:« and »,« criteria »:[],"_signal":« restoreAll »}} ›

try it we have bash script

Thanks Siddic…
below command has been used to get the cookie
curl -b cookie.txt --location --request POST http://localhost:8080/login.jsp --header ‹ Content-Type:application/json › --data-raw ‹ {« username »:« admin », « password »:« admin »} ›

I had created cookie.txt in local.

I can see the cookie is updated in cookie.txt

then I tried to use cookie from CLI for below command

curl -c cookie.txt --location --request POST http://localhost:8080/ws/action --header ‹ Content-Type:application/json › --data-raw ‹ {« model »: « com.axelor.meta.db.MetaView », « action »: « action-meta-restore-all », « data »: {"_ domain": null, « domainContext": {" id »: null, « _ model »: « com.axelor.meta.db.MetaView »}, « operator »: « and », « criteria »: [], « _ signal »: « restoreAll » }} ›

but I was still getting 401 error.

Later I have copied the same cookie in POSTMAN and then I was able to call services

Ce sujet a été automatiquement fermé après 30 jours. Aucune réponse n’est permise dorénavant.