The CreatorCon Call for Content is officially open! Get started here.

REST API task_sla, I can only access 2 records of the table - what is happening?

Victor Mesa
Tera Contributor
I try to access from a rest call of the Rest SNOW API to the records of the task_sla table but the request only returns 2 records of the table. What I can be doing wrong?

It only happens to me with that table, I do the same with the contract_sla table and there I access all the records.

https://xxxxx.service-now.com/api/now/table/task_sla

200 Ok

But only 2 records from the table.


https://xxxxx.service-now.com/api/now/table/task_sla?sysparm_query=task%3D4bea152b875345106402xxxxxxxx
If I try to access a specific record and different from the 2 that it shows me, the response is
200 ok

{
"result": 
}


Thanks for the help
1 ACCEPTED SOLUTION

Mahendra RC
Mega Sage

Hello @Victor Mesa ,

It seems to be some acl or role based access issue with your integration user. Could you please check once the ACL or role that your integration user has.

If you try to get the task_sla data using the admin user you should be able to get other task_sla data as well. I am able to get the task_sla data using admin user in my PDI instance.

You can use the below script to GET the task_sla data using admin user (provide admin user's username and password to check). Also replace your instance name.

(function () {

	var RESOURCE_PATH = "/api/now/table/task_sla";
	var request = new sn_ws.RESTMessageV2();
	request.setEndpoint("https://<YOUR_INSTANCE_NAME>.service-now.com/"+RESOURCE_PATH );
	request.setHttpMethod('GET');
	request.setQueryParameter("sysparm_query", "task.active=true");

	//Eg. UserName="admin", Password="admin" for this code sample.
	var user = 'admin';
	var password = 'admin';
	request.setBasicAuth(user,password);

	//gs.print(JSON.stringify(requestBody));
	//request.setRequestBody(JSON.stringify(requestBody));

	request.setRequestHeader("Accept","application/json");
	var response = request.execute();
	var responseBody = response.getBody();
	var responseResult = JSON.parse(responseBody)["result"];
	gs.print(responseResult.length);
	
})();

Please mark my respsone as helpful/correct, if it answer your question.

Thanks

View solution in original post

4 REPLIES 4

Jaspal Singh
Mega Patron
Mega Patron

Hi,

Did you verfiy what is.

?sysparm_query=task%3D4bea152b875345106402xxxxxxxx

It seems to be record sys_id

Yes, that sys_id is from a correct record, but you changed the last characters to "x", sorry.

Mahendra RC
Mega Sage

Hello @Victor Mesa ,

It seems to be some acl or role based access issue with your integration user. Could you please check once the ACL or role that your integration user has.

If you try to get the task_sla data using the admin user you should be able to get other task_sla data as well. I am able to get the task_sla data using admin user in my PDI instance.

You can use the below script to GET the task_sla data using admin user (provide admin user's username and password to check). Also replace your instance name.

(function () {

	var RESOURCE_PATH = "/api/now/table/task_sla";
	var request = new sn_ws.RESTMessageV2();
	request.setEndpoint("https://<YOUR_INSTANCE_NAME>.service-now.com/"+RESOURCE_PATH );
	request.setHttpMethod('GET');
	request.setQueryParameter("sysparm_query", "task.active=true");

	//Eg. UserName="admin", Password="admin" for this code sample.
	var user = 'admin';
	var password = 'admin';
	request.setBasicAuth(user,password);

	//gs.print(JSON.stringify(requestBody));
	//request.setRequestBody(JSON.stringify(requestBody));

	request.setRequestHeader("Accept","application/json");
	var response = request.execute();
	var responseBody = response.getBody();
	var responseResult = JSON.parse(responseBody)["result"];
	gs.print(responseResult.length);
	
})();

Please mark my respsone as helpful/correct, if it answer your question.

Thanks

Hello @Mahendra,

I think the problem is because of ACLS in the Integration User, 
if I assign the administrator role to that user then I can access all the records
of the task_sla table from the rest request.

Thanks