ARTIFACTORY: How to add a federated member using REST API?

ARTIFACTORY: How to add a federated member using REST API?

AuthorFullName__c
Elina Floim
articleNumber
000005280
ft:sourceType
Salesforce
FirstPublishedDate
2022-05-19T15:10:38Z
lastModifiedDate
2024-03-10T08:25:10Z
VersionNumber
5

Adding federated members to a federated repository can be done via the UI, however, it is also possible to add federated members via REST API by using the update repository configuration REST API call. This can be achieved by following these steps:

  1. Get the federated repository configuration by running the repository configuration REST API call
  2. The above request will return a JSON file containing the repository configuration. Paste the JSON response into a file and modify it by adding the desired federated member to the “members” section, as follows:
If the JSON contained these members:
"members" : [ {
    "url" : "http://$ART_HOST1:8082/artifactory/fed",
    "enabled" : true
  }, {
    "url" : "http://$ART_HOST2:8082/artifactory/fed",
    "enabled" : true
  }],
The updated “members” configuration should be the one above, in addition to the new member(s):
"members" : [ {
    "url" : "http://$ART_HOST1:8082/artifactory/fed",
    "enabled" : true
  }, {
    "url" : "http://$ART_HOST2:8082/artifactory/fed",
    "enabled" : true
  }, {
    "url" : "http://$ART_HOST3:8082/artifactory/fed",
    "enabled" : true
  } ],
3. Save the JSON file and use the update repository configuration REST API call by providing the JSON file from section #2 (fed-config.json is the name of the file containing the JSON configuration of the repository):
$ curl -uadmin:password http://ART_HOST/artifactory/api/repositories/$federated_repo_name -XPOST -H "Content-Type: application/json" -T fed-config.json

Note: The repository configuration JSON file that is being used to update the federated repository configuration needs only two mandatory fields in this case - “rclass” and “members”. All the other fields may be removed from the JSON file if desired. An example of the federated repository JSON configuration can be seen here.