PHP script dilini kullanarak ServiceNow’da yamış olduğumuz Scripted REST API çağırma kodunu aşağıda bulabilirsiniz.
//ARRAYofHASH modelindeki verilerinizi dolduracağınız array tanımlaması.
$data = array();
/*
***ÖRNEK VERİ MODELİ***
[{"table_name":"incident","record_sys_id":"79164747db310010cbe8f28239961943","number":"123456","fileFullPath":"demoFiles/SWEP11.PNG","fileName":"SWEP11.PNG","fileMimeType":"","fileB64":"B64FileString"},{"table_name":"incident","record_sys_id":"79164747db310010cbe8f28239961943","number":"123456","fileFullPath":"demoFiles/swep-2.jpg","fileName":"swep-2.jpg","fileMimeType":"","fileB64":"B64FileString"},{"table_name":"incident","record_sys_id":"79164747db310010cbe8f28239961943","number":"123456","fileFullPath":"demoFiles/swep.zip","fileName":"swep.zip","fileMimeType":"","fileB64":"B64FileString"},{"table_name":"incident","record_sys_id":"79164747db310010cbe8f28239961943","number":"123456","fileFullPath":"demoFiles/swep.msg","fileName":"swep.msg","fileMimeType":"","fileB64":"B64FileString"}]
*/
$body = json_encode($data);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://YOUR_INSTENCE_NAME.service-now.com/api/42684/avt_attach",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => array(
"Accept: application/json",
"Content-Type: application/json",
"Authorization: Basic xxx_YOUR_TOKEN_BASIC_OTANTİKASYON_ANAHTARINIZ_xxx"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo "<hr />";
echo $response;
//ARRAYofHASH modelindeki verilerinizi dolduracağınız array tanımlaması.
$data = array();
/*
***ÖRNEK VERİ MODELİ***
[{"table_name":"incident","record_sys_id":"79164747db310010cbe8f28239961943","number":"123456","fileFullPath":"demoFiles/SWEP11.PNG","fileName":"SWEP11.PNG","fileMimeType":"","fileB64":"B64FileString"},{"table_name":"incident","record_sys_id":"79164747db310010cbe8f28239961943","number":"123456","fileFullPath":"demoFiles/swep-2.jpg","fileName":"swep-2.jpg","fileMimeType":"","fileB64":"B64FileString"},{"table_name":"incident","record_sys_id":"79164747db310010cbe8f28239961943","number":"123456","fileFullPath":"demoFiles/swep.zip","fileName":"swep.zip","fileMimeType":"","fileB64":"B64FileString"},{"table_name":"incident","record_sys_id":"79164747db310010cbe8f28239961943","number":"123456","fileFullPath":"demoFiles/swep.msg","fileName":"swep.msg","fileMimeType":"","fileB64":"B64FileString"}]
*/
$body = json_encode($data);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://YOUR_INSTENCE_NAME.service-now.com/api/42684/avt_attach",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => array(
"Accept: application/json",
"Content-Type: application/json",
"Authorization: Basic xxx_YOUR_TOKEN_BASIC_OTANTİKASYON_ANAHTARINIZ_xxx"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo "<hr />";
echo $response;
//ARRAYofHASH modelindeki verilerinizi dolduracağınız array tanımlaması. $data = array(); /* ***ÖRNEK VERİ MODELİ*** [{"table_name":"incident","record_sys_id":"79164747db310010cbe8f28239961943","number":"123456","fileFullPath":"demoFiles/SWEP11.PNG","fileName":"SWEP11.PNG","fileMimeType":"","fileB64":"B64FileString"},{"table_name":"incident","record_sys_id":"79164747db310010cbe8f28239961943","number":"123456","fileFullPath":"demoFiles/swep-2.jpg","fileName":"swep-2.jpg","fileMimeType":"","fileB64":"B64FileString"},{"table_name":"incident","record_sys_id":"79164747db310010cbe8f28239961943","number":"123456","fileFullPath":"demoFiles/swep.zip","fileName":"swep.zip","fileMimeType":"","fileB64":"B64FileString"},{"table_name":"incident","record_sys_id":"79164747db310010cbe8f28239961943","number":"123456","fileFullPath":"demoFiles/swep.msg","fileName":"swep.msg","fileMimeType":"","fileB64":"B64FileString"}] */ $body = json_encode($data); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://YOUR_INSTENCE_NAME.service-now.com/api/42684/avt_attach", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => $body, CURLOPT_HTTPHEADER => array( "Accept: application/json", "Content-Type: application/json", "Authorization: Basic xxx_YOUR_TOKEN_BASIC_OTANTİKASYON_ANAHTARINIZ_xxx" ), )); $response = curl_exec($curl); curl_close($curl); echo "<hr />"; echo $response;