如何使用 REST API 创建新项目并在 fortify ssc 中提交它
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
今天我遇到了同样的错误,因为我特意测试了哪些设置是必要的。您可以尝试单独
调用API
而不是批量更新
。在调用
https://{{YourSscUrl}}/v1/projectVersions
并创建 SSC 版本后,我在下面进行了另外 2 个 API 调用:https://{{YourSscUrl }}/v1/projectVersions/{{YourNewCreatedProjectVersionID}}/attributes
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 ofbulk update
.After I called
https://{{YourSscUrl}}/v1/projectVersions
and created the SSC version, I made another 2 API calls below:https://{{YourSscUrl}}/v1/projectVersions/{{YourNewCreatedProjectVersionID}}/attributes
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
它对我有用:
It is working for me with :
通过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
检查上面 json 响应中显示的 attributedefinitiodId、projectdefinitionId、id、guid(开发阶段/策略等)。
使用上述详细信息,创建有效负载并为您尝试创建的新应用程序执行其余 API 调用。
您可以按照 https://yourfortifysscurl/ssc/html/docs/api-reference/index.jsp 中的 PAYLOAD 中包含的其余 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
Check for the attributedefinitiodId, projectdefinitionId, id, guid(development phase/strategy etc) which are showing in above json response.
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