Click HERE to see how Saviynt Intelligence is transforming the industry. |
09/11/2024 06:06 AM
I'm trying to setup a connection and the parameters must be sent in the body. I've tried several other options in Postman and only sending in Body works.
I believe this is just a syntax issue, but there's no documentation on how to build these.
This body in Postman seems to work:
This is what the curl command looks like:
curl --location --request GET "https://server.website.com/api/v1/token" --header "Content-Type: application/json" --data-raw "grant_type=password&username=USERNAME&password=PASSWORD"
I've tried this and it doesn't seem to work:
{
"authentications": {
"userAuth": {
"authType": "oauth2",
"url": "https://server.website.com/api/v1/token",
"httpMethod": "GETWITHBODY",
"httpParams": "{\"grant_type\"=\"password\"&\"username\"=\"USERNAME\"&\"password\"=\"PASSWORD\"}",
"httpHeaders": {
"Content-Type": "text/plain"
},
"httpContentType": "application/json",
"authError": [
"400"
],
"errorPath": "errorCode",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"authHeaderName": "Authorization",
"accessToken": "Bearer abcd",
"retryFailureStatusCode": [
401
]
}
}
}
09/11/2024 06:40 AM
Use below
{
"authentications": {
"userAuth": {
"authType": "oauth2",
"url": "https://server.website.com/api/v1/token",
"httpMethod": "GETWITHBODY",
"httpParams": {
"grant_type": "password",
"username": "USERNAME",
"password": "PASSWORD"
},
"httpHeaders": {
"Content-Type": "text/plain"
},
"httpContentType": "application/json",
"authError": [
"400"
],
"errorPath": "errorCode",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"authHeaderName": "Authorization",
"accessToken": "Bearer abcd",
"retryFailureStatusCode": [
401
]
}
}
}
09/11/2024 07:22 AM
This didn't seem to work. I added a testConnectionParams section just to remove my Import out of the equation. That didn't work either.
{
"authentications": {
"userAuth": {
"authType": "oauth2",
"url": "https://server.website.com/api/v1/token",
"httpMethod": "GETWITHBODY",
"httpParams": {
"grant_type": "password",
"username": "USERNAME",
"password": "PASSWORD"
},
"httpHeaders": {
"Content-Type": "text/plain"
},
"httpContentType": "application/json",
"authError": [
"400"
],
"errorPath": "errorCode",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"authHeaderName": "Authorization",
"accessToken": "Bearer abcd",
"retryFailureStatusCode": [
401
],
"testConnectionParams": {
"http": {
"url": "https://server.website.com/api/v1/users",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"httpMethod": "GET"
},
"successResponse": [],
"successResponsePath": "",
"errors": [
"Couldn't authenticate you"
],
"errorPath": "error"
}
}
}
}
09/11/2024 08:32 AM
{
"authentications": {
"userAuth": {
"authType": "oauth2",
"url": "https://server.website.com/api/v1/token",
"httpMethod": "GETWITHBODY",
"httpParams": {
"grant_type": "password",
"username": "USERNAME",
"password": "PASSWORD"
},
"httpHeaders": {
"Content-Type": "application/json"
},
"httpContentType": "application/json",
"authError": [
"400"
],
"errorPath": "errorCode",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"authHeaderName": "Authorization",
"accessToken": "Bearer abcd",
"retryFailureStatusCode": [
401
],
"testConnectionParams": {
"http": {
"url": "https://server.website.com/api/v1/users",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"httpMethod": "GET"
},
"successResponse": [],
"successResponsePath": "",
"errors": [
"Couldn't authenticate you"
],
"errorPath": "error"
}
}
}
}
09/11/2024 08:46 AM
That didn't work either
09/11/2024 08:58 AM
Please share logs
09/11/2024 10:34 AM
09/11/2024 10:42 AM
Can you try once with post in postman
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696521634Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] DEBUG rest.RestProvisioningService - Got Webservice API Response: [headers:[Cache-Control: private, Content-Type: application/json; charset=utf-8, Server: Microsoft-IIS/10.0, WWW-Authenticate: Bearer, X-Robots-Tag: noindex, Strict-Transport-Security: max-age=8; includeSubDomains, Date: Wed, 11 Sep 2024 17:29:26 GMT, Content-Length: 61], responseText:{message"":""Authorization has been denied for this request.""}", cookies:[]," statusCode:401]""",,
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696534534Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] DEBUG rest.RestUtilService - pullObjectsByRest - responseStatusCode ::401",,,,
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696657535Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] ERROR rest.RestProvisioningService - Exception in pullObjectsByRest :401",,,,
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696679935Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] ERROR rest.RestProvisioningService - Inside token Expiry Exception block. connectionParamMap.refreshTryCount : 0",,,,
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696693735Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] DEBUG rest.RestProvisioningService - Incrementing connectionParamMap.refreshTryCount : 1",,,,
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696701835Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] DEBUG rest.RestProvisioningService - maxRefreshTryCount : 5",,,,
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696808835Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] DEBUG rest.RestUtilService - Calling https://server.website.com/api/v1/token",,,,
09/11/2024 11:55 AM
POST definitely works in Postman, I was trying to switch to GET as they both work and I only saw getwithbody and nothing for POST. I had already tried a few things with POST.
09/11/2024 11:57 AM
Share logs with POST
09/11/2024 12:23 PM
09/11/2024 02:21 PM
It seems your credentials are wrong or have some special characters
09/12/2024 05:20 AM
The credentials do have special characters. Do I need to escape them somehow?
09/12/2024 06:47 AM
@Bwagne
Try changing the password and test it.
09/12/2024 07:59 AM
Can you let us know what all special characters in password ?
09/12/2024 08:04 AM
@ and . are both in there
Can't change the password as it is a service account used for many things.
09/12/2024 08:06 AM
It should not cause issue.
Does hardcoded token works ?
09/12/2024 11:03 AM
Haven't setup with a hardtoken but found your post on that.
I tried this and it still failed:
{
"authentications": {
"userAuth": {
"authType": "oauth2",
"url": "https://server.website.com/api/v1/token",
"httpMethod": "POST",
"httpParams": "",
"httpHeaders": {
"Content-Type": "application/json"
},
"httpContentType": "application/json",
"authError": [
"400"
],
"errorPath": "errorCode",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"authHeaderName": "Authorization",
"accessToken": "Bearer tokenvalue",
"token":"tokenvalue",
"retryFailureStatusCode": [
401
],
"testConnectionParams": {
"http": {
"url": "https://server.website.com/api/v1/users",
"httpHeaders": {
"Authorization": "${token}"
},
"httpContentType": "application/json",
"httpMethod": "GET"
},
"successResponse": [],
"successResponsePath": "",
"errors": [
"Couldn't authenticate you"
],
"errorPath": "error"
}
}
}
}
09/12/2024 11:04 AM
I originally set it to ${connection.token} but that didn't make sense and also didn't work
09/12/2024 11:17 AM
@Bwagne
Try using the below values in the import JSON. as you have hardcoded the value.
${token}
${access_token}
09/12/2024 11:22 AM
"Authorization": "${access_token}"
In test connection param
09/11/2024 02:38 PM
@Bwagne Can you test with below Json.
{
"authentications": {
"userAuth": {
"authType": "oauth2",
"url": "https://server.website.com/api/v1/token",
"httpMethod": "GETWITHBODY",
"httpParams": "{\"grant_type\":\"password\",\"username\":\"USERNAME\",\"password\":\"PASSWORD\"}",
"httpHeaders": {
"Content-Type": "application/json"
},
"httpContentType": "application/json",
"authError": [
"400"
],
"errorPath": "errorCode",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"authHeaderName": "Authorization",
"accessToken": "Bearer abcd",
"retryFailureStatusCode": [
401
]
}
}
}