Not knowing where to start in using REST API for creating ServiceNow incidents
I need to update a webform which was used to create incident tickets with a SOAP API. Now it needs to be used with a REST API by ServiceNow and frankly speaking, I don't know where to start.
The existing webform works as follows:
After filling out the form and pressing on the submit-button the "submit.js" is triggered. This function posts all the information in the webform to the "soapclient.php". This soapclient.php connects to the SOAP client and transfers all the data to the SOAP API.
The "soapclient.php" looks as follows:
<?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' => "$descriptionn$timestring$errorstring$phonestring",
'resolveImmediately' => $resolveimmediately,
'solutionCode' => $solutioncode,
'solution' => $solutionstring
)));
$response = $client->SubmitIntApiIncident($request);
I'm pretty sure that I only have to change the "soapclient.php" into using the new REST API instead of the SOAP API. But this is the part where I have NO idea where to start. The REST API uses an API key + a generic user (which I both have) - but I don't know WHERE to use them.
The only clue that I have is a swagger.json file I could download. This KINDA looks like the structure I'm looking for, but I have no idea how to use it.
The "swagger.json" looks as follows:
{
"swagger" : "2.0",
"host" : "send-dev.servicenow.com",
"basePath" : "/api/ServiceNow/devb/incident/v2.5",
"schemes" : [ "https" ],
"paths" : {
"/incident/createIncidentMethod" : {
"post" : {
"description" : "Create incidentn",
"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"
}
}
I would be incredibly grateful if anyone could give me a hint on how to use the new API or how to change the soapclient.php to work with the new API.
Best
Tim
php rest api swagger servicenow
|
show 1 more comment
I need to update a webform which was used to create incident tickets with a SOAP API. Now it needs to be used with a REST API by ServiceNow and frankly speaking, I don't know where to start.
The existing webform works as follows:
After filling out the form and pressing on the submit-button the "submit.js" is triggered. This function posts all the information in the webform to the "soapclient.php". This soapclient.php connects to the SOAP client and transfers all the data to the SOAP API.
The "soapclient.php" looks as follows:
<?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' => "$descriptionn$timestring$errorstring$phonestring",
'resolveImmediately' => $resolveimmediately,
'solutionCode' => $solutioncode,
'solution' => $solutionstring
)));
$response = $client->SubmitIntApiIncident($request);
I'm pretty sure that I only have to change the "soapclient.php" into using the new REST API instead of the SOAP API. But this is the part where I have NO idea where to start. The REST API uses an API key + a generic user (which I both have) - but I don't know WHERE to use them.
The only clue that I have is a swagger.json file I could download. This KINDA looks like the structure I'm looking for, but I have no idea how to use it.
The "swagger.json" looks as follows:
{
"swagger" : "2.0",
"host" : "send-dev.servicenow.com",
"basePath" : "/api/ServiceNow/devb/incident/v2.5",
"schemes" : [ "https" ],
"paths" : {
"/incident/createIncidentMethod" : {
"post" : {
"description" : "Create incidentn",
"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"
}
}
I would be incredibly grateful if anyone could give me a hint on how to use the new API or how to change the soapclient.php to work with the new API.
Best
Tim
php rest api swagger servicenow
It looks like send-dev.servicenow.com from your swagger.json is unavailable - so first question - where is the working service with that API ?
– Kamil Kiełczewski
Nov 21 '18 at 11:16
To "run" swagger.json (visualise it and send requests) use swagger-ui swagger.io/tools/swagger-ui (there is also dockerized version: hub.docker.com/r/swaggerapi/swagger-ui (to easy run using docker) )
– Kamil Kiełczewski
Nov 21 '18 at 11:18
Hi Kamil, thanks for your quick answer. I did not want to divulge what company I am working for which was the reason for me to edit the source code before posting.
– Tim Kühn
Nov 21 '18 at 11:19
I probably not uderstand your question. You can go to editor.swagger.io put your json (it has 2 bugs - tip: remove " ") on left - and see request on right. Using that API you can make only one request POST send-dev.servicenow.com/api/ServiceNow/devb/incident/v2.5/…
– Kamil Kiełczewski
Nov 21 '18 at 11:23
So your swagger.json describe only one API request. You need to ask API provider how to "login" to that API
– Kamil Kiełczewski
Nov 21 '18 at 11:25
|
show 1 more comment
I need to update a webform which was used to create incident tickets with a SOAP API. Now it needs to be used with a REST API by ServiceNow and frankly speaking, I don't know where to start.
The existing webform works as follows:
After filling out the form and pressing on the submit-button the "submit.js" is triggered. This function posts all the information in the webform to the "soapclient.php". This soapclient.php connects to the SOAP client and transfers all the data to the SOAP API.
The "soapclient.php" looks as follows:
<?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' => "$descriptionn$timestring$errorstring$phonestring",
'resolveImmediately' => $resolveimmediately,
'solutionCode' => $solutioncode,
'solution' => $solutionstring
)));
$response = $client->SubmitIntApiIncident($request);
I'm pretty sure that I only have to change the "soapclient.php" into using the new REST API instead of the SOAP API. But this is the part where I have NO idea where to start. The REST API uses an API key + a generic user (which I both have) - but I don't know WHERE to use them.
The only clue that I have is a swagger.json file I could download. This KINDA looks like the structure I'm looking for, but I have no idea how to use it.
The "swagger.json" looks as follows:
{
"swagger" : "2.0",
"host" : "send-dev.servicenow.com",
"basePath" : "/api/ServiceNow/devb/incident/v2.5",
"schemes" : [ "https" ],
"paths" : {
"/incident/createIncidentMethod" : {
"post" : {
"description" : "Create incidentn",
"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"
}
}
I would be incredibly grateful if anyone could give me a hint on how to use the new API or how to change the soapclient.php to work with the new API.
Best
Tim
php rest api swagger servicenow
I need to update a webform which was used to create incident tickets with a SOAP API. Now it needs to be used with a REST API by ServiceNow and frankly speaking, I don't know where to start.
The existing webform works as follows:
After filling out the form and pressing on the submit-button the "submit.js" is triggered. This function posts all the information in the webform to the "soapclient.php". This soapclient.php connects to the SOAP client and transfers all the data to the SOAP API.
The "soapclient.php" looks as follows:
<?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' => "$descriptionn$timestring$errorstring$phonestring",
'resolveImmediately' => $resolveimmediately,
'solutionCode' => $solutioncode,
'solution' => $solutionstring
)));
$response = $client->SubmitIntApiIncident($request);
I'm pretty sure that I only have to change the "soapclient.php" into using the new REST API instead of the SOAP API. But this is the part where I have NO idea where to start. The REST API uses an API key + a generic user (which I both have) - but I don't know WHERE to use them.
The only clue that I have is a swagger.json file I could download. This KINDA looks like the structure I'm looking for, but I have no idea how to use it.
The "swagger.json" looks as follows:
{
"swagger" : "2.0",
"host" : "send-dev.servicenow.com",
"basePath" : "/api/ServiceNow/devb/incident/v2.5",
"schemes" : [ "https" ],
"paths" : {
"/incident/createIncidentMethod" : {
"post" : {
"description" : "Create incidentn",
"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"
}
}
I would be incredibly grateful if anyone could give me a hint on how to use the new API or how to change the soapclient.php to work with the new API.
Best
Tim
php rest api swagger servicenow
php rest api swagger servicenow
asked Nov 21 '18 at 11:10
Tim Kühn
1719
1719
It looks like send-dev.servicenow.com from your swagger.json is unavailable - so first question - where is the working service with that API ?
– Kamil Kiełczewski
Nov 21 '18 at 11:16
To "run" swagger.json (visualise it and send requests) use swagger-ui swagger.io/tools/swagger-ui (there is also dockerized version: hub.docker.com/r/swaggerapi/swagger-ui (to easy run using docker) )
– Kamil Kiełczewski
Nov 21 '18 at 11:18
Hi Kamil, thanks for your quick answer. I did not want to divulge what company I am working for which was the reason for me to edit the source code before posting.
– Tim Kühn
Nov 21 '18 at 11:19
I probably not uderstand your question. You can go to editor.swagger.io put your json (it has 2 bugs - tip: remove " ") on left - and see request on right. Using that API you can make only one request POST send-dev.servicenow.com/api/ServiceNow/devb/incident/v2.5/…
– Kamil Kiełczewski
Nov 21 '18 at 11:23
So your swagger.json describe only one API request. You need to ask API provider how to "login" to that API
– Kamil Kiełczewski
Nov 21 '18 at 11:25
|
show 1 more comment
It looks like send-dev.servicenow.com from your swagger.json is unavailable - so first question - where is the working service with that API ?
– Kamil Kiełczewski
Nov 21 '18 at 11:16
To "run" swagger.json (visualise it and send requests) use swagger-ui swagger.io/tools/swagger-ui (there is also dockerized version: hub.docker.com/r/swaggerapi/swagger-ui (to easy run using docker) )
– Kamil Kiełczewski
Nov 21 '18 at 11:18
Hi Kamil, thanks for your quick answer. I did not want to divulge what company I am working for which was the reason for me to edit the source code before posting.
– Tim Kühn
Nov 21 '18 at 11:19
I probably not uderstand your question. You can go to editor.swagger.io put your json (it has 2 bugs - tip: remove " ") on left - and see request on right. Using that API you can make only one request POST send-dev.servicenow.com/api/ServiceNow/devb/incident/v2.5/…
– Kamil Kiełczewski
Nov 21 '18 at 11:23
So your swagger.json describe only one API request. You need to ask API provider how to "login" to that API
– Kamil Kiełczewski
Nov 21 '18 at 11:25
It looks like send-dev.servicenow.com from your swagger.json is unavailable - so first question - where is the working service with that API ?
– Kamil Kiełczewski
Nov 21 '18 at 11:16
It looks like send-dev.servicenow.com from your swagger.json is unavailable - so first question - where is the working service with that API ?
– Kamil Kiełczewski
Nov 21 '18 at 11:16
To "run" swagger.json (visualise it and send requests) use swagger-ui swagger.io/tools/swagger-ui (there is also dockerized version: hub.docker.com/r/swaggerapi/swagger-ui (to easy run using docker) )
– Kamil Kiełczewski
Nov 21 '18 at 11:18
To "run" swagger.json (visualise it and send requests) use swagger-ui swagger.io/tools/swagger-ui (there is also dockerized version: hub.docker.com/r/swaggerapi/swagger-ui (to easy run using docker) )
– Kamil Kiełczewski
Nov 21 '18 at 11:18
Hi Kamil, thanks for your quick answer. I did not want to divulge what company I am working for which was the reason for me to edit the source code before posting.
– Tim Kühn
Nov 21 '18 at 11:19
Hi Kamil, thanks for your quick answer. I did not want to divulge what company I am working for which was the reason for me to edit the source code before posting.
– Tim Kühn
Nov 21 '18 at 11:19
I probably not uderstand your question. You can go to editor.swagger.io put your json (it has 2 bugs - tip: remove " ") on left - and see request on right. Using that API you can make only one request POST send-dev.servicenow.com/api/ServiceNow/devb/incident/v2.5/…
– Kamil Kiełczewski
Nov 21 '18 at 11:23
I probably not uderstand your question. You can go to editor.swagger.io put your json (it has 2 bugs - tip: remove " ") on left - and see request on right. Using that API you can make only one request POST send-dev.servicenow.com/api/ServiceNow/devb/incident/v2.5/…
– Kamil Kiełczewski
Nov 21 '18 at 11:23
So your swagger.json describe only one API request. You need to ask API provider how to "login" to that API
– Kamil Kiełczewski
Nov 21 '18 at 11:25
So your swagger.json describe only one API request. You need to ask API provider how to "login" to that API
– Kamil Kiełczewski
Nov 21 '18 at 11:25
|
show 1 more comment
1 Answer
1
active
oldest
votes
Your swagger.json
is not valid JSON (however it has small bugs easy to remove - on line 23 and 26 remove " "
before brace). You can view that file in https://editor.swagger.io/. That file describe only one request:
POST http://send-dev.servicenow.com/api/ServiceNow/devb/incident/v2.5/incident/createIncidentMethod
To send request (POST with proper json in body) to that API form php you can use GUZZLE library instead SoapClient
(guzzle has good documentation).
In swagger.json you have only following information:
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.
but without details - however it is used key word "Basic Authentication". So you can try to add following header to your POST request:
Authorization: Basic username:password_base64
Where username:password_base64 is your credentials code by base64 - as example for user demo
and pass p@55w0rd
you need to code base64 string "demo:p@55w0rd" and to add header:
Authorization: Basic ZGVtbzpwQDU1dzByZA==
(it should be use with http/ssl because base64 is easy to decode). If this will not work, then you need to ask your API provider: how to "login" to that API (some API need only additional path parameter like `?key=abc...xyz').
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410847%2fnot-knowing-where-to-start-in-using-rest-api-for-creating-servicenow-incidents%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your swagger.json
is not valid JSON (however it has small bugs easy to remove - on line 23 and 26 remove " "
before brace). You can view that file in https://editor.swagger.io/. That file describe only one request:
POST http://send-dev.servicenow.com/api/ServiceNow/devb/incident/v2.5/incident/createIncidentMethod
To send request (POST with proper json in body) to that API form php you can use GUZZLE library instead SoapClient
(guzzle has good documentation).
In swagger.json you have only following information:
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.
but without details - however it is used key word "Basic Authentication". So you can try to add following header to your POST request:
Authorization: Basic username:password_base64
Where username:password_base64 is your credentials code by base64 - as example for user demo
and pass p@55w0rd
you need to code base64 string "demo:p@55w0rd" and to add header:
Authorization: Basic ZGVtbzpwQDU1dzByZA==
(it should be use with http/ssl because base64 is easy to decode). If this will not work, then you need to ask your API provider: how to "login" to that API (some API need only additional path parameter like `?key=abc...xyz').
add a comment |
Your swagger.json
is not valid JSON (however it has small bugs easy to remove - on line 23 and 26 remove " "
before brace). You can view that file in https://editor.swagger.io/. That file describe only one request:
POST http://send-dev.servicenow.com/api/ServiceNow/devb/incident/v2.5/incident/createIncidentMethod
To send request (POST with proper json in body) to that API form php you can use GUZZLE library instead SoapClient
(guzzle has good documentation).
In swagger.json you have only following information:
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.
but without details - however it is used key word "Basic Authentication". So you can try to add following header to your POST request:
Authorization: Basic username:password_base64
Where username:password_base64 is your credentials code by base64 - as example for user demo
and pass p@55w0rd
you need to code base64 string "demo:p@55w0rd" and to add header:
Authorization: Basic ZGVtbzpwQDU1dzByZA==
(it should be use with http/ssl because base64 is easy to decode). If this will not work, then you need to ask your API provider: how to "login" to that API (some API need only additional path parameter like `?key=abc...xyz').
add a comment |
Your swagger.json
is not valid JSON (however it has small bugs easy to remove - on line 23 and 26 remove " "
before brace). You can view that file in https://editor.swagger.io/. That file describe only one request:
POST http://send-dev.servicenow.com/api/ServiceNow/devb/incident/v2.5/incident/createIncidentMethod
To send request (POST with proper json in body) to that API form php you can use GUZZLE library instead SoapClient
(guzzle has good documentation).
In swagger.json you have only following information:
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.
but without details - however it is used key word "Basic Authentication". So you can try to add following header to your POST request:
Authorization: Basic username:password_base64
Where username:password_base64 is your credentials code by base64 - as example for user demo
and pass p@55w0rd
you need to code base64 string "demo:p@55w0rd" and to add header:
Authorization: Basic ZGVtbzpwQDU1dzByZA==
(it should be use with http/ssl because base64 is easy to decode). If this will not work, then you need to ask your API provider: how to "login" to that API (some API need only additional path parameter like `?key=abc...xyz').
Your swagger.json
is not valid JSON (however it has small bugs easy to remove - on line 23 and 26 remove " "
before brace). You can view that file in https://editor.swagger.io/. That file describe only one request:
POST http://send-dev.servicenow.com/api/ServiceNow/devb/incident/v2.5/incident/createIncidentMethod
To send request (POST with proper json in body) to that API form php you can use GUZZLE library instead SoapClient
(guzzle has good documentation).
In swagger.json you have only following information:
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.
but without details - however it is used key word "Basic Authentication". So you can try to add following header to your POST request:
Authorization: Basic username:password_base64
Where username:password_base64 is your credentials code by base64 - as example for user demo
and pass p@55w0rd
you need to code base64 string "demo:p@55w0rd" and to add header:
Authorization: Basic ZGVtbzpwQDU1dzByZA==
(it should be use with http/ssl because base64 is easy to decode). If this will not work, then you need to ask your API provider: how to "login" to that API (some API need only additional path parameter like `?key=abc...xyz').
edited Nov 21 '18 at 13:14
answered Nov 21 '18 at 11:48
Kamil Kiełczewski
8,93085788
8,93085788
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410847%2fnot-knowing-where-to-start-in-using-rest-api-for-creating-servicenow-incidents%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It looks like send-dev.servicenow.com from your swagger.json is unavailable - so first question - where is the working service with that API ?
– Kamil Kiełczewski
Nov 21 '18 at 11:16
To "run" swagger.json (visualise it and send requests) use swagger-ui swagger.io/tools/swagger-ui (there is also dockerized version: hub.docker.com/r/swaggerapi/swagger-ui (to easy run using docker) )
– Kamil Kiełczewski
Nov 21 '18 at 11:18
Hi Kamil, thanks for your quick answer. I did not want to divulge what company I am working for which was the reason for me to edit the source code before posting.
– Tim Kühn
Nov 21 '18 at 11:19
I probably not uderstand your question. You can go to editor.swagger.io put your json (it has 2 bugs - tip: remove " ") on left - and see request on right. Using that API you can make only one request POST send-dev.servicenow.com/api/ServiceNow/devb/incident/v2.5/…
– Kamil Kiełczewski
Nov 21 '18 at 11:23
So your swagger.json describe only one API request. You need to ask API provider how to "login" to that API
– Kamil Kiełczewski
Nov 21 '18 at 11:25