- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017 04:29 AM
Hi Khozema,
Following is the example using PHP using cURL library. I have fetched information from incident table where number is INC0010062
What is cURL library:
1) name of package on server
2) used to access data from outside web pages
3) mostly used for accessing third party systems using API
4) supports http, https protocol
Execute it here online to verify: Free Online IDE and Terminal
past the php code and execute it
Sample php Code:
<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://instanceName.service-now.com/api/now/table/incident?sysparm_query=number=INC0010062");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl,CURLOPT_USERPWD,"rest.user:rest.user"); // username:password format
$result = curl_exec($curl);
curl_close($curl);
print($result);
?>
</body>
</html>
Sample output:
<body>
{"result":[{"parent":"","made_sla":"true","caused_by":"","watch_list":"6816f79cc0a8016401c5a33be04be441,e0459c414f962200fc11fa218110c726","upon_reject":"cancel","sys_updated_on
":"2017-08-18 12:52:33","child_incidents":"0","approval_history":"","skills":"","number":"INC0010062","resolved_by":"","sys_updated_by":"admin","opened_by":{"link":"https://instanceName.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441","value":"6816f79cc0a8016401c5a33be04be441"},"user_input":"","sys_created_on":"2017-08-18 12:52:33
","sys_domain":{"link":"https://instanceName.service-now.com/api/now/table/domain/09ff3d105f231000b12e3572f2b4775d","value":"09ff3d105f231000b12e3572f2b4775d"},"state":"1","task_fo
r":"","sys_created_by":"admin","knowledge":"false","order":"","calendar_stc":"","closed_at":"","cmdb_ci":"","impact":"3","active":"true","work_notes_list":"","business_service"
:"","priority":"5","sys_domain_path":"!!!/!!!/!!#/","rfc":"","time_worked":"","expected_start":"","opened_at":"2017-08-18 12:52:33","business_duration":"","group_list":"","vz_r
elease_for_test_datetime":"","work_end":"","caller_id":"","resolved_at":"","approval_set":"","subcategory":"","work_notes":"","short_description":"Incident created from web ser
vice","close_code":"","correlation_display":"","work_start":"","assignment_group":"","additional_assignee_list":"","business_stc":"","description":"","calendar_duration":"","vz
_release_for_test":"","close_notes":"","notify":"1","sys_class_name":"incident","closed_by":"","follow_up":"","parent_incident":"","sys_id":"19d1eed74fe40300fc11fa218110c768","
incident_state":"1","urgency":"3","problem_id":"","u_dell_correlation_id":"","company":"","reassignment_count":"0","activity_due":"","assigned_to":"","severity":"3","comments":
"","approval":"not requested","sla_due":"","comments_and_work_notes":"","due_date":"","sys_mod_count":"0","reopen_count":"0","sys_tags":"","u_my_currency":"0","escalation":"0",
"upon_approval":"proceed","correlation_id":"","location":"","category":"inquiry"}]}</body>
</html>
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader