如何使用 REST API 创建新项目并在 fortify ssc 中提交它

发布于 2025-01-11 04:15:31 字数 2969 浏览 0 评论 0原文

我正在尝试使用 REST api 在 fortify 中创建一个新项目,到目前为止我已经能够创建应用程序和版本,但我无法向其添加属性并提交它。 到目前为止,这是我的代码。 这是我用来提交的脚本。

import requests

headers = {
'accept': 'application/json',
'Authorization': 'FortifyToken MmRjODVjZjctOWE2Zi00NGQxLWFkZTAtZmE2ZjUxZmZiYmU1',
'Content-Type': 'application/json',
}

json_data={
"requests": [
{
"uri": "http://localhost:8080/ssc/api/v1/projectVersions/6491/attributes",
"httpVerb": "PUT",
"postData": [
{
"attributeDefinitionId": 1,
"values": [
{
"guid": "High"
}
]
},
{
"guid":"DevPhase",
"attributeDefinitionId":"2",
"values": [
{
"guid":"Active"
}
]
} ,
{
"guid":"Accessibility",
"attributeDefinitionId":"3",
"values": [
{"guid":"externalpublicnetwork"}
]
},
{
"guid":"DevStrategy",
"attributeDefinitionId":"4",
"values": [
{"guid":"Internal"}
]
}
]

},

{

"uri": "http://localhost:8080/ssc/api/v1/projectVersions/6491?hideProgress=true",
"httpVerb": "PUT",
"postData": {
"committed": "true",
}
}
]
}
response = requests.post('localhost:8080/.../bulk', headers=headers, json=json_data)

the header that I provided works fine.

这是我收到的错误。

{u'count': 2, u'successCount': 0, u'data': [{u'request': {u'uri': u'http://shortterm-2075.rg5.emdevinfrabom.oraclevcn.com:8080/ssc/api/v1/projectVersions/6491/attributes', u'postData': u'[{"attributeDefinitionId":1,"values":[{"guid":"High"}]},{"attributeDefinitionId":"5307","guid":"DevPhase","values":[{"guid":"Active"}]},{"attributeDefinitionId":"5319","guid":"Accessibility","values":[{"guid":"externalpublicnetwork"}]},{"attributeDefinitionId":"5312","guid":"DevStrategy","values":[{"guid":"Internal"}]}]', u'httpVerb': u'PUT'}, u'responses': [{u'body': {u'errorCode': -12300, u'message': u'Missing meta data definitions.', u'responseCode': 400}, u'headers': {}, u'requestUrl': u'http://localhost:8080/ssc/api/v1/projectVersions/6491/attributes'}]}, {u'request': {u'uri': u'shortterm-2075.rg5.emdevinfrabom.oraclevcn.com:8080/.../6491, u'postData': u'{"committed":"true"}', u'httpVerb': u'PUT'}, u'responses': [{u'body': {u'errorCode': -12301, u'message': u'A required application attribute definition is missing a value: Development Phase.', u'responseCode': 400}, u'headers': {}, u'requestUrl': u'http://localhost:8080/ssc/api/v1/projectVersions/6491?hideProgress=true'}]}], u'responseCode': 200}

这是提交“所需的应用程序属性定义缺少值:开发阶段”时出现的错误,并且在发布到其属性时发生此错误所需的应用程序属性定义缺少值:开发阶段.', u'responseCode': 400

我浏览了很多社区论坛,但找不到任何相关的解决方案。 有人可以帮我吗?

I am trying to create a new project in fortify using REST api and so far I have been able to create the application and version,but I am not able to add attributes to it and commit it.
Here is my code so far.
Here is my script that I am using to commit.

import requests

headers = {
'accept': 'application/json',
'Authorization': 'FortifyToken MmRjODVjZjctOWE2Zi00NGQxLWFkZTAtZmE2ZjUxZmZiYmU1',
'Content-Type': 'application/json',
}

json_data={
"requests": [
{
"uri": "http://localhost:8080/ssc/api/v1/projectVersions/6491/attributes",
"httpVerb": "PUT",
"postData": [
{
"attributeDefinitionId": 1,
"values": [
{
"guid": "High"
}
]
},
{
"guid":"DevPhase",
"attributeDefinitionId":"2",
"values": [
{
"guid":"Active"
}
]
} ,
{
"guid":"Accessibility",
"attributeDefinitionId":"3",
"values": [
{"guid":"externalpublicnetwork"}
]
},
{
"guid":"DevStrategy",
"attributeDefinitionId":"4",
"values": [
{"guid":"Internal"}
]
}
]

},

{

"uri": "http://localhost:8080/ssc/api/v1/projectVersions/6491?hideProgress=true",
"httpVerb": "PUT",
"postData": {
"committed": "true",
}
}
]
}
response = requests.post('localhost:8080/.../bulk', headers=headers, json=json_data)

the header that I provided works fine.

this is the error that I am getting.

{u'count': 2, u'successCount': 0, u'data': [{u'request': {u'uri': u'http://shortterm-2075.rg5.emdevinfrabom.oraclevcn.com:8080/ssc/api/v1/projectVersions/6491/attributes', u'postData': u'[{"attributeDefinitionId":1,"values":[{"guid":"High"}]},{"attributeDefinitionId":"5307","guid":"DevPhase","values":[{"guid":"Active"}]},{"attributeDefinitionId":"5319","guid":"Accessibility","values":[{"guid":"externalpublicnetwork"}]},{"attributeDefinitionId":"5312","guid":"DevStrategy","values":[{"guid":"Internal"}]}]', u'httpVerb': u'PUT'}, u'responses': [{u'body': {u'errorCode': -12300, u'message': u'Missing meta data definitions.', u'responseCode': 400}, u'headers': {}, u'requestUrl': u'http://localhost:8080/ssc/api/v1/projectVersions/6491/attributes'}]}, {u'request': {u'uri': u'shortterm-2075.rg5.emdevinfrabom.oraclevcn.com:8080/.../6491, u'postData': u'{"committed":"true"}', u'httpVerb': u'PUT'}, u'responses': [{u'body': {u'errorCode': -12301, u'message': u'A required application attribute definition is missing a value: Development Phase.', u'responseCode': 400}, u'headers': {}, u'requestUrl': u'http://localhost:8080/ssc/api/v1/projectVersions/6491?hideProgress=true'}]}], u'responseCode': 200}

this is the error while committing "A required application attribute definition is missing a value: Development Phase" and this one while posting to its attributes A required application attribute definition is missing a value: Development Phase.', u'responseCode': 400

I went through many community forums and could not find any related solution.
Can someone please help me here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

执手闯天涯 2025-01-18 04:15:31

今天我遇到了同样的错误,因为我特意测试了哪些设置是必要的。您可以尝试单独调用API而不是批量更新

在调用 https://{{YourSscUrl}}/v1/projectVersions 并创建 SSC 版本后,我在下面进行了另外 2 个 API 调用:

  1. https://{{YourSscUrl }}/v1/projectVersions/{{YourNewCreatedProjectVersionID}}/attributes

  2. https://{{YourSscUrl}}/v1/projectVersions/{{ YourNewCreatedProjectVersionID}}?hideProgress=true

然后我也调用了以下API,但它不会影响错误。

https://{{YourSscUrl}}/v1/projectVersions/{{YourNewCreatedProjectVersionID}}/职责

I got the same error today as I purposely test which setting is necessary. You can try to call API separately instead of bulk update.

After I called https://{{YourSscUrl}}/v1/projectVersions and created the SSC version, I made another 2 API calls below:

  1. https://{{YourSscUrl}}/v1/projectVersions/{{YourNewCreatedProjectVersionID}}/attributes

  2. https://{{YourSscUrl}}/v1/projectVersions/{{YourNewCreatedProjectVersionID}}?hideProgress=true

Then I called following API as well, but it doesn't affect the error.

https://{{YourSscUrl}}/v1/projectVersions/{{YourNewCreatedProjectVersionID}}/responsibilities

冷月断魂刀 2025-01-18 04:15:31

它对我有用:

{
   "requests":[
      {
         "uri":"http://localhost:8080/ssc/api/v1/projectVersions/[ID]/attributes",
         "httpVerb":"PUT",
         "postData":[
            {
               "attributeDefinitionId":5,
               "values":[
                  {
                     "guid":"Active"
                  }
               ],
               "value":null
            },
            {
               "attributeDefinitionId":1,
               "values":[
                  {
                     "guid":"High"
                  }
               ],
               "value":null
            },
            {
               "attributeDefinitionId":6,
               "values":[
                  {
                     "guid":"Customized"
                  }
               ],
               "value":null
            },
            {
               "attributeDefinitionId":7,
               "values":[
                  {
                     "guid":"consoleaccess"
                  }
               ],
               "value":null
            }
         ]
      },
      {
         "uri":"http://localhost:8080/ssc/api/v1/projectVersions/[ID]?hideProgress=true",
         "httpVerb":"PUT",
         "postData":{
            "committed":true
         }
      }
   ]
}

It is working for me with :

{
   "requests":[
      {
         "uri":"http://localhost:8080/ssc/api/v1/projectVersions/[ID]/attributes",
         "httpVerb":"PUT",
         "postData":[
            {
               "attributeDefinitionId":5,
               "values":[
                  {
                     "guid":"Active"
                  }
               ],
               "value":null
            },
            {
               "attributeDefinitionId":1,
               "values":[
                  {
                     "guid":"High"
                  }
               ],
               "value":null
            },
            {
               "attributeDefinitionId":6,
               "values":[
                  {
                     "guid":"Customized"
                  }
               ],
               "value":null
            },
            {
               "attributeDefinitionId":7,
               "values":[
                  {
                     "guid":"consoleaccess"
                  }
               ],
               "value":null
            }
         ]
      },
      {
         "uri":"http://localhost:8080/ssc/api/v1/projectVersions/[ID]?hideProgress=true",
         "httpVerb":"PUT",
         "postData":{
            "committed":true
         }
      }
   ]
}
素染倾城色 2025-01-18 04:15:31
  1. 搜索 fortify 中的任何现有应用程序

通过rest api curl -X POST 'https://yourfortifysscurl/ssc/api/v1/projectVersions' --header 'accept: application/json' --header 'Authorization: FortifyToken MmRjODVjZjctOWE2Zi00NGQxLWFkZTAtZmE2ZjUxZmZiYmU1' -- 标头'Content-Type: application/json' -o response.json

查找已在 fortify 中创建的任何应用程序(已处于开发阶段、已设置策略并能够扫描),并在上面获得的响应中搜索该应用程序名称。 json

  1. 检查上面 json 响应中显示的 attributedefinitiodId、projectdefinitionId、id、guid(开发阶段/策略等)。

  2. 使用上述详细信息,创建有效负载并为您尝试创建的新应用程序执行其余 API 调用。

您可以按照 https://yourfortifysscurl/ssc/html/docs/api-reference/index.jsp 中的 PAYLOAD 中包含的其余 api 语法和值进行操作

  1. Search for any existing application in fortify via rest api

curl -X POST 'https://yourfortifysscurl/ssc/api/v1/projectVersions' --header 'accept: application/json' --header 'Authorization: FortifyToken MmRjODVjZjctOWE2Zi00NGQxLWFkZTAtZmE2ZjUxZmZiYmU1' --header 'Content-Type: application/json' -o response.json

Look for any application that is already created in fortify (which has development phase, strategy set already and able to scan) and search for that application name in the above obtained response.json

  1. Check for the attributedefinitiodId, projectdefinitionId, id, guid(development phase/strategy etc) which are showing in above json response.

  2. Use the above details, create the payload and perform the rest api call for your new application you are trying to create.

You can follow - the rest api syntax and values to be included in PAYLOAD at https://yourfortifysscurl/ssc/html/docs/api-reference/index.jsp

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文