'How to create a new project and commit it in fortify ssc using REST API

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.



Solution 1:[1]

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

Solution 2:[2]

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
         }
      }
   ]
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hamza Sharuf
Solution 2 Hardy Francois