JSON データ変更 API
HTTPS POST 要求をインスタンスに送信し、JSON Web サービスを使用してデータを変更します。
sysparm_action パラメーターと、本文に受信 JSON オブジェクト post が含まれている必要があります。insert
ServiceNow で新しいレコードを作成します。JSON オブジェクトは本文として POST する必要があります (content-type は通常 application/json ですが、強制はされません)。レコード作成からの応答は、作成されたインシデントの JSON オブジェクトです。
{"short_description":"this is a test","priority":"1"}https://your_instance.service-now.com/incident.do?JSONv2&sysparm_action=insertこれでインシデントが作成されます。
{"sysparm_action":"insert","short_description":"this is a test","priority":"1"}insertMultiple
{ "records" : [ { "short_description" : "this was inserted with python using JSON 1" , "priority" : "1 - Critical" , "impact" : "1" , "caller_id" : "Fred Luddy" } , { "short_description" : "this was inserted with python using JSON 2" , "priority" : "1 - Critical" , "impact" : "1" , "caller_id" : "Fred Luddy" } ] }https://<instance name>.service-now.com/incident.do?JSONv2&sysparm_action=insert
https://<instance name>.service-now.com/incident.do?JSONv2&sysparm_action=insertMultiple
これで 2 つのインシデントが作成されます。フィールドが records フィールドのアレイ値として記述されていることに注意してください。
update
sysparm_query URL パラメーターで指定されたエンコードクエリ文字列でフィルタリングされたレコードまたはレコードリストを更新します。JSON オブジェクトは本文として POST する必要があります (content-type は通常 application/json ですが、強制はされません)。レコード作成からの応答は、更新されたレコードを表す JSON オブジェクトのアレイです。
{"short_description":"this was updated with python", "priority": "3", "impact":"1"}https://instance_name.service-now.com/incident.do?JSONv2&sysparm_query=priority=3&sysparm_action=update
優先度 3 のすべてのインシデントを更新し、JSON オブジェクトで指定された値を設定します。
deleteRecord
sysparm_sys_id パラメーターで識別される単一のレコードをターゲットテーブルから削除します。パラメーターは、入力 JSON オブジェクトでエンコードするか、URL パラメーターとして指定できます。
{"sysparm_sys_id":"fd4001f80a0a0b380032ffa2b749927b"}
http://instance_name.service-now.com/incident.do?JSONv2&sysparm_action=deleteRecord
sys_id fd4001f80a0a0b380032ffa2b749927b で識別されるインシデントレコードを削除します。
deleteMultiple
sysparm_query URL パラメーターで指定されたエンコードクエリ文字列でフィルタリングされた複数のレコードを、ターゲットテーブルから削除します。フィルターは、入力 JSON オブジェクトでエンコードすることもできます。
{"sysparm_query":"short_description=this was updated with python"}http://instance_name.service-now.com/incident.do?JSONv2&sysparm_action=deleteMultipleshort_description フィールドに「this was updated with python」という値が含まれているすべてのインシデントレコードを削除します。