Мне нужно обновить веб-форму, которая использовалась для создания заявок на инциденты с помощью SOAP API.Теперь его нужно использовать с REST API от ServiceNow, и, честно говоря, я не знаю с чего начать.
Существующая веб-форма работает следующим образом: после заполнения формы и нажатия кнопки подтверждения"submit.js" запущен.Эта функция отправляет всю информацию в веб-форме в "soapclient.php".Этот soapclient.php подключается к SOAP-клиенту и передает все данные в SOAP API.
«soapclient.php» выглядит следующим образом:
<?php
$wsdl =wsdl-server;
$client = new SoapClient($wsdl, array('login' => "USER",
'password' => "PW“,
'trace'=> 1));
$title = $_REQUEST['title'];
$affuser = $_REQUEST['affuser'];
$description = $_REQUEST['description'];
$solutionstring = '';
$solutioncode = '';
$resolveimmediately = '';
[[SEVERAL IF-ELSE STATEMENTS]]
$request = array(
'model'=>array(
'keys'=>array(),
'instance'=>array(
'registrationId' => ID,
'affectedUserId' => $affuser,
'serviceId' => $serviceId,
'affectedCiId' => '',
'priority' => '4',
'title' => $title,
'description' => "$description\n$timestring$errorstring$phonestring",
'resolveImmediately' => $resolveimmediately,
'solutionCode' => $solutioncode,
'solution' => $solutionstring
)));
$response = $client->SubmitIntApiIncident($request);
Я уверен, чтоМне нужно только изменить "soapclient.php" на использование нового REST API вместо SOAP API.Но это та часть, где я понятия не имею, с чего начать.REST API использует ключ API + общий пользователь (который у меня есть) - но я не знаю, ГДЕ их использовать.
Единственный ключ, который у меня есть, - это файл swagger.json, который я могу загрузить,Этот KINDA выглядит как структура, которую я ищу, но я не знаю, как ее использовать.
"swagger.json" выглядит следующим образом:
{
"swagger" : "2.0",
"host" : "send-dev.servicenow.com",
"basePath" : "/api/ServiceNow/devb/incident/v2.5",
"schemes" : [ "https" ],
"paths" : {
"/incident/createIncidentMethod" : {
"post" : {
"description" : "Create incident\n",
"operationId" : "POST /incident/createIncidentMethod",
"parameters" : [ {
"description" : "Create Incident",
"required" : false,
"in" : "body",
"name" : "body",
"schema" : {
"properties" : {
"header" : {
"properties" : {
"transactionid" : {
"type" : "string"
},
"sourcesystemid" : ""{
"type" : "string"
},
"targetsystemid" : " "{
"type" : "string"
}
},
"type" : "object"
},
"content" : {
"properties" : {
"caller_id" : {
"type" : "string"
},
"category" : {
"type" : "string"
},
"subcategory" : {
"type" : "string"
},
"business_service" : {
"type" : "string"
},
"ci_name" : {
"type" : "string"
},
"impact" : {
"type" : "string"
},
"urgency" : {
"type" : "string"
},
"assignment_group" : {
"type" : "string"
},
"assigned_to" : {
"type" : "string"
},
"short_description" : {
"type" : "string"
},
"state" : {
"type" : "string"
},
"close_code" : {
"type" : "string"
},
"close_notes" : {
"type" : "string"
},
"service_offering" : {
"type" : "string"
},
"affected_user" : {
"type" : "string"
},
"description" : {
"type" : "string"
},
"correlation_id" : {
"type" : "string"
},
"ci_sysid" : {
"type" : "string"
}
},
"type" : "object"
},
"attachment" : {
"properties" : {
"file_name" : {
"type" : "string"
},
"mime_type" : {
"type" : "string"
},
"base64string" : {
"type" : "string"
}
},
"type" : "object"
}
},
"type" : "object"
}
} ],
"responses" : {
"200" : {
"description" : "Success",
"schema" : {
"type" : "object"
}
},
"401" : {
"description" : "Not authorized",
"schema" : {
"type" : "object"
}
},
"610" : {
"description" : "User doesn't exist.",
"schema" : {
"type" : "object"
}
},
"611" : {
"description" : "Group doesn't exist.",
"schema" : {
"type" : "object"
}
},
"612" : {
"description" : "User is not member of the group.",
"schema" : {
"type" : "object"
}
},
"613" : {
"description" : "Incident State is invalid.",
"schema" : {
"type" : "object"
}
},
"405" : {
"description" : "Not supported. Invalid parameters.",
"schema" : {
"type" : "object"
}
},
"603" : {
"description" : "Missing mandatory information.",
"schema" : {
"type" : "object"
}
},
"614" : {
"description" : "Incident Category is invalid.",
"schema" : {
"type" : "object"
}
},
"615" : {
"description" : "Incident Subcategory is invalid.",
"schema" : {
"type" : "object"
}
},
"616" : {
"description" : "Only one input is allowed. Configuration item Name or SysId.",
"schema" : {
"type" : "object"
}
},
"606" : {
"description" : "Record not found.",
"schema" : {
"type" : "object"
}
},
"618" : {
"description" : "CI name is not unique."
},
"608" : {
"description" : "Impact is invalid. Impact must be 1, 2 or 3.",
"schema" : {
"type" : "object"
}
},
"609" : {
"description" : "Urgency is invalid. Urgency must be 1, 2 or 3.",
"schema" : {
"type" : "object"
}
}
}
}
}
},
"info" : {
"title" : "ServiceNow Incident v2.5",
"description" : "This REST API provides methods to create/update/retrieve ITSM incident module data from ServiceNow. This API uses Basic authentication (plus API Key). If there is a need to consume from outside the network, there is another version of this API that is configured for two factor authentication.",
"version" : "1.0.0",
"x-summary" : "SNOW Incident API"
}
}
Я был быневероятно благодарен, если кто-нибудь может дать мне подсказку о том, как использовать новый API или как изменить soapclient.php для работы с новым API.
Best Tim