使用API​​调用创建“立即服务”目录项时遇到必填字段缺失错误

时间:2019-11-20 17:42:00

标签: servicenow servicenow-rest-api

我正在使用ServiceNow API创建目录请求。

URL:

https://<ServiceNow>/api/sn_sc/servicecatalog/items/6e2cc01d4f51ce08d4fb2b8ca310c7a6/order_now

身体:

{
    "sysparm_quantity":"1",
    "variables":  {
        "requestor":"6e2cc01d4f51ce08d4fb2b8ca310c7a6",
        "Requested For":"6e2cc01d4f51ce08d4fb2b8ca310c7a6",
        "Group Name":"01304c6ddbef9f0827673672399619c4",
        "Group Domain":"FG",
        "Rationale for Approver Only (this will not be viewed by fulfillment team)":"testing"
    }
}

我收到此错误:

{
    "error": {
        "detail": "",
        "message": "Mandatory Variables are required"
    },
    "status": "failure"
}

我怎么知道什么是必填字段?

2 个答案:

答案 0 :(得分:0)

我发现此ID将用于获取必需变量。 https://<ServiceNow>/api/sn_sc/servicecatalog/items/<Item_ID>/variables

但是,我现在不在官方文档中找到此服务。不知道这是否是API扩展。

答案 1 :(得分:0)

在打开表单的同时检查浏览器(F12,Chrome)中的elements标签,并搜索“ variable_tab”,您将在其中看到所有预期的变量。您可以通过查看表单来了解强制性调用的方式。