The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Integration

kirankr2061
Tera Contributor
var apipath = '/api/now/table/sys_user_grmember';
var username = 'Automation';
var pass = 'xxx';
var asgrpid = 'e666528b939e2ad4e2cb3af17cba109a'; // Group sys id in qa
var value = '84a4d1df87758510735aba2c8bbb3559'; // User sys id

var r = new sn_ws.RESTMessageV2();
r.setHttpMethod('POST');
r.setEndpoint(qaurl + apipath);
r.setRequestHeader('Accept', 'application/json');
r.setRequestHeader('Content-Type', 'application/json');
r.setBasicAuth(username, pass);

var body = {
    "group": asgrpid.toString(),
    "user": value.toString(),
};

r.setRequestBody(JSON.stringify(body));
gs.print("Request body: " + r.getRequestBody());

var response = r.execute();
var statusCode = response.getStatusCode();
var responseBody = response.getBody();

gs.print("Status: " + statusCode);
gs.print("Response: " + responseBody);

var parsed = JSON.parse(responseBody);
if (parsed.result) {
    gs.print("Created sys_id: " + parsed.result.sys_id);
}
I am trying to give access to other people from my instance but problem is record is getting created with empty values please suggest me any solution
4 REPLIES 4

GlideFather
Tera Patron

Hi @kirankr2061,

 

if you want to give access to your PDI for other people, then create their user profiles and set passwords and they will have the access as per granted to them (portal x backend etc).

 

What's the code above about?

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Through a catalog item request I am trying to give access to others 

@kirankr2061 
And why don’t you add the access through a group membership?

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


He is existing user I just need to give access to those