An existing application can be updated by means of a PATCH
request. The following procedure adds a project to the application, but you can change any
part of the application record, for example: change the application name, update the
description, or move the application to the trash.
Only Organization Administrators can perform this step.
-
Request all applications and filter on the name of your application.
This step finds the application in question so you can retrieve the application id and etag, which are necessary in a later step.
Request:
curl --location --request GET HTTPS://domain.cop.blackduck.com/api/common/v0/applications?filter[application][name][$isubstr]=docs-application-7.22.2021&page[limit]=1&page[offset]=0About this request:
- The filtering parameters
(
filter[project][name][$isubstr]=docs-webgoat) limit the results to the application named, "docs-application-7.22.2021." For more about filtering see the Generic House Keeping page in the Swagger reference documentation. - A page limit is required. The page limit and offset parameters
(
page[limit]=1andpage[offset]=0) limit the results to one record and apply no offset (offset omits the first n results). - To use this example, insert your base URL in place of
domain.cop.blackduckin the URL.
Response:
{ "data": [ { "type": "application", "id": "a66178cc-2fc0-4c2e-ad7b-d0292955e806", "attributes": { "name": "docs-application-7.22.2021", "description": "Application created by the docs team" }, "relationships": { "projects": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/applications/a66178cc-2fc0-4c2e-ad7b-d0292955e806/relationships/projects", "related": "https://subdomain.cop.blackduck.com/api/common/v0/applications/a66178cc-2fc0-4c2e-ad7b-d0292955e806/related/projects" }, "data": [ { "type": "project", "id": "3038d1a4-2124-49e5-9aed-02570a3e400d" }, { "type": "project", "id": "aa545462-2eda-4bc6-8c5e-e996fa822bf8" } ] } }, "links": { "self": { "href": "https://subdomain.cop.blackduck.com/api/common/v0/applications/a66178cc-2fc0-4c2e-ad7b-d0292955e806", "meta": { "durable": "urn:x-swip:applications:a66178cc-2fc0-4c2e-ad7b-d0292955e806" } } }, "meta": { "etag": "W/\"u2fnb2guhb749rbo2kt6aut62vdvme6cpbrfk0de86cefrj4f0jkh1munv3d99trpv2\ 9anmh9s4urc3q5tbehj63okg0gatujfagkzpb80eapvj2819j4m1j2plvbblg\"", "organization-id": "fl1v7rb3ol7gj9l4hh9lntmpfc", "in-trash": false, "project-count": 2 } } ], "included": [], "meta": { "offset": 0, "limit": 1, "total": 1 }, "links": { "next": null, "prev": null, "first": "https://subdomain.cop.blackduck.com/api/common/v0/applications?page%5Blimit%5D=1&page%5Boffset%5D=0&filter%5Bapplication%5D%5Bname%5D%5B%24isubstr%5D=SIG-docs-application-7.22.2021&tenant-id=fl1v7rb3ol7gj9l4hh9lntmpfc", "last": "https://subdomain.cop.blackduck.com/api/common/v0/applications?page%5Blimit%5D=1&page%5Boffset%5D=0&filter%5Bapplication%5D%5Bname%5D%5B%24isubstr%5D=SIG-docs-application-7.22.2021&tenant-id=fl1v7rb3ol7gj9l4hh9lntmpfc" } }You will need the entire response object when updating the application. In addition to copying the object, retrieve the application id and the latest etag. All these are required in the last step.
- The filtering parameters
(
-
Request all projects and filter on the name of the project that you want to add
to your application.
This step retrieves the project id, which is necessary in a later step.
Request:
curl --location --request GET HTTPS://domain.cop.blackduck.com/api/common/v0/projects?filter[project][name][$isubstr]=docs-webgoat&page[limit]=1&page[offset]=0About this request:
- The filtering parameters
(
filter[project][name][$isubstr]=docs-webgoat) limit the results to the project named, "docs-webgoat." For more about filtering see the Generic House Keeping page in the Swagger reference documentation. - A page limit is required. The page limit and offset parameters
(
page[limit]=1andpage[offset]=0) limit the results to one record and apply no offset (An offset omits the first n results).
{ "data": [ { "type": "project", "id": "3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b", "attributes": { "type": "REPOSITORY", "properties": {}, "name": "docs-webgoat", "description": null }, "relationships": { "project-preference": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/relationships/project-preference", "related": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/related/project-preference" }, "data": { "type": "project-preference", "id": "c48529d9-835b-4a09-a5ea-f50a084f3435" } }, "user-default-branch": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/relationships/user-default-branch", "related": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/related/user-default-branch" }, "data": { "type": "branch", "id": "313d3b4a-f0f7-42bc-be5c-5f946f4163db" } }, "runs": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/relationships/runs", "related": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/related/runs" } }, "branches": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/relationships/branches", "related": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b/related/branches" } } }, "links": { "self": { "href": "https://subdomain.cop.blackduck.com/api/common/v0/projects/3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b", "meta": { "durable": "urn:x-swip:projects:3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b" } } }, "meta": { "etag": "W/\"poaenn8372rgb699hnad6r487oped3j2p4th\ tg85imqqmsopkdstnnto0vfiqhmclb6r7cl823amo1anou99rtaqspk7elft10\ rn3dtsoq7a86oj190gzjmtrctp4iaho28kmevg24kjiuc\"", "organization-id": "fl1v7rb3ol7gj9l4hh9lntmpfc", "in-trash": false } } ], "included": [], "meta": { "offset": 0, "limit": 1, "total": 1 }, "links": { "next": null, "prev": null, "first": "https://subdomain.cop.blackduck.com/api/common/v0/projects?page%5Blimit%5D=1&page%5Boffset%5D=0&filter%5Bproject%5D%5Bname%5D%5B%24isubstr%5D=docs-webgoat&tenant-id=fl1v7rb3ol7gj9l4hh9lntmpfc", "last": "https://subdomain.cop.blackduck.com/api/common/v0/projects?page%5Blimit%5D=1&page%5Boffset%5D=0&filter%5Bproject%5D%5Bname%5D%5B%24isubstr%5D=docs-webgoat&tenant-id=fl1v7rb3ol7gj9l4hh9lntmpfc" } }Retrieve the project id.
- The filtering parameters
(
-
Add the project to the application.
Note: Applications are limited to 200 projects.
Request:
curl --location --request PATCH "https://domain.cop.blackduck.com/api/common/v0/applications/a66178cc-2fc0-4c2e-ad7b-d0292955e806" \ --header Authorization: Bearer {JWT} --header "accept: application/vnd.api+json" \ --header "Content-Type: application/vnd.api+json" \ --header "If-Match: W/"u2fnb2guhb749rbo2kt6aut62vdvme6cpbrfk\ 0de86cefrj4f0jkh1munv3d99trpv2r62j6iulblod5flrhfdfq9anmh9s4urc3q\ 5tbehj63okg0gatujfagkzpb80eapvj2819j4m1j2plvbblg"" --data \ { "data": { "type": "application", "id": "a66178cc-2fc0-4c2e-ad7b-d0292955e806", "attributes": { "name": "docs-application-7.22.2021", "description": "Application created by the docs team" }, "relationships": { "projects": { "data": [ { "type": "project", "id": "3038d1a4-2124-49e5-9aed-02570a3e400d" }, { "type": "project", "id": "aa545462-2eda-4bc6-8c5e-e996fa822bf8" }, { "type": "project", "id": "3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b" } ] } } } } }About this request:
- The final part of the URL is the application id.
- The header If_Match: {etag} is required for
PATCHrequests. - Use the request body after amending it to make your changes. In this request, a third project is added to the application, using the project id retrieved in the previous step.
- Properties named meta, links, and included have been removed from the application record. These aren't required for POST and PATCH operations.
Response:
{ "data": { "type": "application", "id": "a66178cc-2fc0-4c2e-ad7b-d0292955e806", "attributes": { "name": "docs-application-7.22.2021", "description": "Application created by the docs team" }, "relationships": { "projects": { "links": { "self": "https://subdomain.cop.blackduck.com/api/common/v0/applications/a66178cc-2fc0-4c2e-ad7b-d0292955e806/relationships/projects", "related": "https://subdomain.cop.blackduck.com/api/common/v0/applications/a66178cc-2fc0-4c2e-ad7b-d0292955e806/related/projects" }, "data": [ { "type": "project", "id": "3038d1a4-2124-49e5-9aed-02570a3e400d" }, { "type": "project", "id": "3a3c3c16-ee71-4c91-bff7-a5f2016dcb7b" }, { "type": "project", "id": "aa545462-2eda-4bc6-8c5e-e996fa822bf8" } ] } }, "links": { "self": { "href": "https://subdomain.cop.blackduck.com/api/common/v0/applications/a66178cc-2fc0-4c2e-ad7b-d0292955e806", "meta": { "durable": "urn:x-swip:applications:a66178cc-2fc0-4c2e-ad7b-d0292955e806" } } }, "meta": { "etag": "W/\"ljcpo23ousdch2711r5ssnn5d4c34uhdqkmcemjp5\ uudjhh6jg80v03pjjac8ldr718udgv6dl8ndhhu85487ne1tgjrt0nk6mt2ukr9\ 438dpq7a3b0etiomlkz9dm0tbrtv5jr19pjdbeckpm1ug\"", "organization-id": "fl1v7rb3ol7gj9l4hh9lntmpfc", "in-trash": false, "project-count": 3 } }, "included": [], "meta": { "offset": 0, "limit": 10, "total": 1 }, "links": { "next": null, "prev": null, "first": "https://subdomain.cop.blackduck.com/api/common/v0/applications/a66178cc-2fc0-4c2e-ad7b-d0292955e806?tenant-id=fl1v7rb3ol7gj9l4hh9lntmpfc&page%5Boffset%5D=0", "last": "https://subdomain.cop.blackduck.com/api/common/v0/applications/a66178cc-2fc0-4c2e-ad7b-d0292955e806?tenant-id=fl1v7rb3ol7gj9l4hh9lntmpfc&page%5Boffset%5D=0" } }This response confirms that the record is updated to contain the third project.