Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Import Account with Graph QL via REST connection

ejeong
Valued Contributor
Valued Contributor

Here is payload to get users

curl --location --request POST

'https://demo.sourcegraph.com/.api/graphql' \

--header 'Authorization: token [Token]' \

--header 'Content-Type: application/json' \

--data-raw '{"query":"query {\n users(activePeriod:ALL_TIME ) {\n totalCount\n nodes {\n username,\n siteAdmin,\n usageStatistics {\n lastActiveTime\n }\n \t}\n }\n}","variables":{}}'

And here is response.

Can anyone help me how to make JSON for importAccountJSON with REST connector in this case?

Example response

{

"data": {

"users": {

"totalCount":

2,

"nodes": [

{

"username":

"sourcegraph-user 2",

"siteAdmin":

true,

"usageStatistics": {

"lastActiveTime":

"2022-11-15T09:58:55Z"

}

},

{

"username":

"user2",

"siteAdmin":

true,

"usageStatistics": {

"lastActiveTime":

"2022-09-08T18:23:28Z"

}

} ] } } }

15 REPLIES 15

rushikeshvartak
All-Star
All-Star

Share your draft version of json, Looking at response its doable.


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

"httpParam" : {"query":"query {\n users(activePeriod:ALL_TIME ) {\n totalCount\n nodes {\n username,\n siteAdmin,\n usageStatistics {\n lastActiveTime\n }\n \t}\n }\n}","variables":{}}

I am wondering in httpParam part in importAccountJSON. Could you please let me know if I need to add \n or \t for graphQL?

Here is response I can get via Postman

ejeong_1-1669077483391.png

Query I used

query {

users(activePeriod:ALL_TIME ) {

totalCount

nodes {

username,

siteAdmin,

usageStatistics {

lastActiveTime

}

}

}
}

ejeong_0-1669077447973.png

\n \t you can ignore

click on code option in postman to check how its getting passed in curl url


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

thanks. let me try it

This is JSON I configured and I tried to import accounts.

{
"accountParams": {
"connection": "acctAuth",
"createUsers": false,
"processingType": "SequentialAndIterative",
"statusAndThresholdConfig": {
"deleteLinks": true,
"accountThresholdValue": 50,
"correlateInactiveAccounts": false,
"accountsNotInImportAction": "NOACTION",
"inactivateAccountsNotInFile": false,
"deleteAccEntForActiveAccounts": true
},
"call": {
"call1": {
"callOrder": 0,
"stageNumber": 0,
"disableDeletedAccounts": true,
"http": {
"url": "url",
"httpMethod": "POST",
"httpHeaders": {
"contentType": "application/json",
"Authorization": "token token",
"Accept": "application/json"
},
"httpParams": {
"query": "query {users(activePeriod:ALL_TIME ) {totalCount nodes {id,username,siteAdmin,usageStatistics {lastActiveTime}}}}"
},
"listField": "data.nodes",
"keyField": "accountID",
"colsToPropsMap": {
"accountID": "id~#~char",
"name": "username~#~char",
"displayName": "username~#~char",
"customproperty1": "siteAdmin~#~char"
},
"unsuccessResponses": {
"statusCode": [
400,
403,
401,
404,
409,
405,
500
]
}
}
}
}
}
}

I am getting error like below.

ejeong_0-1669100586887.png

"httpContentType": "application/json",


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Thanks. I added it but still get same error.

{
"accountParams": {
"connection": "acctAuth",
"createUsers": false,
"processingType": "SequentialAndIterative",
"statusAndThresholdConfig": {
"deleteLinks": true,
"accountThresholdValue": 50,
"correlateInactiveAccounts": false,
"accountsNotInImportAction": "NOACTION",
"inactivateAccountsNotInFile": false,
"deleteAccEntForActiveAccounts": true
},
"call": {
"call1": {
"callOrder": 0,
"stageNumber": 0,
"disableDeletedAccounts": true,
"http": {
"url": "url",
"httpContentType": "application/json",
"httpMethod": "POST",
"httpHeaders": {
"contentType": "application/json",
"Authorization": "token token",
"Accept": "application/json"
},
"httpParams": {
"query": "query {users(activePeriod:ALL_TIME ) {totalCount nodes {id,username,siteAdmin,usageStatistics {lastActiveTime}}}}"
},
"listField": "data.nodes",
"keyField": "accountID",
"colsToPropsMap": {
"accountID": "id~#~char",
"name": "username~#~char",
"displayName": "username~#~char",
"customproperty1": "siteAdmin~#~char"
},
"unsuccessResponses": {
"statusCode": [
400,
403,
401,
404,
409,
405,
500
]
}
}
}
}
}
}

ejeong
Valued Contributor
Valued Contributor

here is error.

java.lang.NullPointerException: Cannot invoke method trim() on null object
at com.saviynt.provisoning.rest.RestProvisioningService.persistAccounts(RestProvisioningService.groovy:4711)
at com.saviynt.provisoning.rest.RestProvisioningService.processAccountsByPagination(RestProvisioningService.groovy:4060)
at com.saviynt.provisoning.rest.RestProvisioningService.processAccounts(RestProvisioningService.groovy:3967)
at com.saviynt.provisoning.rest.RestProvisioningService$_processAccountsFinal_closure11_closure78.doCall(RestProvisioningService.groovy:1634)
at com.saviynt.provisoning.rest.RestProvisioningService$_processAccountsFinal_closure11.doCall(RestProvisioningService.groovy:1630)
at com.saviynt.provisoning.rest.RestProvisioningService.processAccountsFinal(RestProvisioningService.groovy:1629)
at com.saviynt.provisoning.rest.RestProvisioningService.processAccountsFullBySequentialAndIterative(RestProvisioningService.groovy:1591)
at com.saviynt.provisoning.rest.RestProvisioningService.importAccountsFull(RestProvisioningService.groovy:1422)
at com.saviynt.provisoning.rest.RestProvisioningService.doImport(RestProvisioningService.groovy:136)
at com.saviynt.ecm.integration.ExternalConnectionCallService.invokeExternalMethod(ExternalConnectionCallService.groovy:187)
at SapImportJob.execute(SapImportJob.groovy:104)
at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)

Does connection name is correct ?

"listField": "data.nodes" try "listField": "nodes",


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

it's correct name, also I think I need to add "data.nodes". Here is sample response

{
"data": {
"users": {
"totalCount": 121,
"nodes": [
{
"id": "VXNlcjox",
"username": "sourcegraph-admin",
"siteAdmin": true,
"usageStatistics": {
"lastActiveTime": "2022-11-21T16:39:10Z"
}
},

ejeong
Valued Contributor
Valued Contributor

I tried "data.users.nodes" as well but didn't work.

One thing I found is.. when trying from postman, it is taking around 11 second to get response. would it be matter?

ejeong_0-1669131961016.png

that should not matter, are you passing proper Authorization


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Yes. Even i am trying by hardcoding token in import account json..

Btw, by looking response above,

Whats correct list field would be?

here is full response. could you please let me know what would be listfield to get id ?

ejeong_0-1669154427815.png

Can you tell what should be the Listfield value in the Accountimport json?

I am facing this issue while configuring the connector.