Get Session Not working

curl -X POST "https://dev.abdm.gov.in/gateway/v0.5/sessions" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"clientId\":\"SBX_002648\",\"clientSecret\":\"XXXX-XXXX....\"}"

above curl is generated by swagger doc and the curl will work from terminal but doesn’t work when request executed from swagger doc itself. when making a request from my REST client in code it won’t work from there as well and will give 401 error with null response body.

Following is the log of the request in code:

Request: POST https://dev.abdm.gov.in/gateway/0.5/sessions 

Headers[Accept=application/json Content-Type=application/json User-Agent=Resteasy Reactive Client content-length=79], 
Body:
{"clientId":"SBX_002648","clientSecret":"XXXX-XXXX..."}

2023-02-17 20:06:51,045 DEBUG [org.jbo.res.rea.cli.log.DefaultClientLogger] (vert.x-eventloop-thread-0) 
Response: 
POST https://dev.abdm.gov.in/gateway/0.5/sessions, Status[401 Unauthorized], 
Headers[www-authenticate=Basic realm="Realm" cache-control=no-cache, 
no-store,max-age=0, must-revalidate pragma=no-cache expires=0 
x-content-type-options=nosniff strict-transport-security=max-age=31536000 ; 
includeSubDomains x-frame-options=DENY x-xss-protection=1 ; mode=block 
referrer-policy=no-referrer content-length=0 x-envoy-upstream-service-time=3 
date=Fri, 17 Feb 2023 14:36:50 GMT
Set-Cookie=TS011c04bd=01445fed04ccc8a6129801edd8929277b58e942162b3f883caa4f4824b50e85ef34d9a3c94ac4375a68cc2cbccfcc0d48256187fe4; Path=/],

Body:

Am I missing something here? Please help me on this as am stuck on this for a while. I am using Quarkus Rest Client library to make requests. This library has worked for other services we are using but not able to understand why it is not working here.

@IntegrationSupport, Please help on this. Do we have any User-Agent restriction?

Hi @dinesh2.solanki - Kindly check with the following curl:

curl --location ‘https://dev.ndhm.gov.in/gateway/v0.5/sessions
–header ‘Content-Type: application/json’
–header ‘Cookie: TS01960242=01445fed04c93df2cd14f140347d99cbe2bff77c2b127ebcc15e24f326913f201ac48bedaea37177c873cc21fd2a52a05acd682431’
–data ‘{
“clientId”: “xxxxxxx”,
“clientSecret”: “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”,
“grantType”: “client_credentials”
}’

Thank You!

Hi @atulsharma ,

Like i said, Curl works but request in code doesn’t work and gives 401 error. Is the Cookie header mandatory? Please read the topic properly to understand the problem

@dinesh2.solanki - Import the given curl in postman. Set your credentials and try again.

@atulsharma, @Ramandeep1 is the cookie header mandatory? my request is failing in code so trying to debug.
Are there any restriction on User Agent? Following is the request being generated in code:

Request: POST https://dev.abdm.gov.in/gateway/0.5/sessions
Headers[Accept=application/json Content-Type=application/json User-Agent=Resteasy Reactive Client content-length=112],
Body:
{“clientId”:“SBX_002648”,“clientSecret”:“XXXX-XXXX…”,“grantType”:“client_credentials”}

@dinesh2.solanki - Use this url - https://dev.abdm.gov.in/gateway/v0.5/sessions

Cookie header is not mandatory.

Hi, I have tried with local and my company domain, in the both case, it only shows CORS error s follows.
i have try all of ways

API : https://live.abdm.gov.in/gateway/v0.5/sessions
method : POST
payload:
{
“clientId”: “XYZ_002020”,
“clientSecret”: “xxxxx-xxxxx-xxxxxx-xxxxxxx-xxxxxx”,
“grantType”:“client_credentials”
}

headers: {
‘Content-Type’: ‘application/json’,
‘Cookie’: ‘TS011c04bd=01445fed04917f4e4898c8b8811fc36c38d165c81ab9f7a203ab326410b295ea525b22c9988a8c48f6b53be2f7a7abb2dfbb10f1f5’
},

Please help me on this as am stuck on this for a while. I am using axios in react to make requests.

Hi @atulsharma,

have you got any solution related to session API?

Thanks
Prem K

any solution on this ?

Hi,
Request: POST https://dev.abdm.gov.in/gateway/0.5/sessions
this api responded fine but after few minutes getting below response.
{

"error": {

    "code": "ABDM-1920: ",

    "message": "Invalid grant type"

}

}
plz check and update.