Import set API response

Varun Batra
Tera Expert

Hi all, 

Is there any way to customize Import set api response to send only specific fields. For example in response we get(refer to screenshot) contains certain values like import set, table name, etc. What i am trying to achieve is to only send the u_number field in the response.

find_real_file.pngIn the third party tool i am using below as the parameter: 

/api/now/import/u_manager_request_starter_staging?sysparm_display_value=true&sysparm_fields=u_number. 
 
Even though i have specified it to only send u_number, still it send the response attached above

 

1 ACCEPTED SOLUTION

Varun Batra
Tera Expert

Thanks Ankush and Vipin,

I made it working by using table API but for that i created a field in import set table(source table) named as u_number and then stored response in that field using onAfter Script.

(function runTransformScript(source, map, log, target){

source.u_number = target.u_number;
source.update();

})(source, map, log, target);

And then i have to modify query parameter at end point to below: 

/api/now/table/tablename?sysparm_display_value=true&sysparm_fields=u_number

 

View solution in original post

3 REPLIES 3

vipinmathew
Mega Guru

Hi Varun,

 

As per my understanding , the fields which are showing is system fields.

That you cannot remove it from OOB Import Set API. IF you want custom response ,

you can go for Scripted REST API.

 

OR

 

use Table API instead of Import Set API and do your action.

find_real_file.png

 

Thanks

Vipin Mathew

 

note: mark helpful , if it is useful for you.

Ankush Jangle1
Kilo Guru

Hi Varun,

 

1) If you are using Rest Message Module Then the Whole Response will Come.

2)you have to use Scripted Rest Api to Send the number in Response.

 

find_real_file.png

Please Mark it as Helpful/Correct if it Helps you

Varun Batra
Tera Expert

Thanks Ankush and Vipin,

I made it working by using table API but for that i created a field in import set table(source table) named as u_number and then stored response in that field using onAfter Script.

(function runTransformScript(source, map, log, target){

source.u_number = target.u_number;
source.update();

})(source, map, log, target);

And then i have to modify query parameter at end point to below: 

/api/now/table/tablename?sysparm_display_value=true&sysparm_fields=u_number