Modify Project Properties

Coverity on Polaris

Version
latest
You can add or remove project properties by sending a PATCH request.

Organization administrators can modify project properties and other project attributes.

Project properties are key/value pairs designated by any contributor to the project. They're useful if you want to associate your project number or other internal identifiers with the project. Each project can have up to five project properties. Use the following process to modify them.

  1. Retrieve project information.
    GET https://subdomain.cop.blackduck.com/api/common/v0/projects/{project_id}

    Response:

     {
      "data": 
        {
          "type": "project",
          "id": "ccc82255-a7db-4e9d-ac3a-ebb61664daca",
          "attributes": {
             "properties": {
              "additionalProp1": "val1",
              "additionalProp2": "val2",
              "additionalProp3": "val3"
            }
            "name": "200207-2024-gvipi7"
          },
          "relationships": {},
          "links": {
            "self": {
              "href": "https://subdomain.cop.blackduck.com/api/common/v0/projects/ccc82255-a7db-4e9d-ac3a-ebb61664daca",
              "meta": {
                "durable": "urn:x-skip:projects:ccc82255-a7db-4e9d-ac3a-ebb61664daca"
              }
            }
          },
          "meta": {
            "etag": "w/4cf186a0ad7cde51ba1e99a98166a55fccc0d57f",
            "organization-id": "6a4epmhfv93h5fpqfb9cubpchs",
            "in-trash": false
          }
        },
    }
                          
                        
    The following values are required from that response:
    • data.id (The same id you used to retrieve the project information.)
    • meta.etag
    • data.attributes.properties

    The etag value is required whenever you make a PATCH request to the common object service. You must submit the most recent etag value for the object to submit the request. This prevents simultaneous editing by multiple users.

    Note: If the properties object exists, copy the entire contents. The PATCH request is the only way to modify properties. Thus, you must submit all the existing properties in the request, because of the nature of the PATCH request. Any existing properties not included in your request are removed from the project.
  2. Modify the properties in the body of your request.
    You can add, delete, or change properties as you wish, but keep in mind that the maximum number of properties is five per project. Property keys are allowed to contain alphanumeric characters, underscores, and dashes – nothing else. The values for those keys don't have the same restrictions.
    PATCH https://subdomain.cop.blackduck.com/api/common/v0/projects/{project_id}
    -H Authorization: Bearer {token} 
    Content-Type: application/vnd.api+json
    If-Match: {etag_value}
    
    {
      "data": 
        {
          "type": "project",
          "attributes": {
            "name": "Skip-fandeck-project5",
            "properties": {
                "additionalProp1": "val1",
                "customId":"8675309",
                "group":"Polaris"
            }
          }
        }
    }

    This request removes the properties additionalProp2 and additionalProp3, which were present in the Step 1 example. It adds the new values customId and group.

    Remember to include the etag and an authentication token with the request.

    The response is similar to the response in step 1, with the exception of the amended properties and a new etag.