# Use API to add custom catalog

**URL:** <https://forums.suse.com/t/use-api-to-add-custom-catalog/2324>\
**Category:** Rancher 1.x\
**Created:** [April 5, 2016, 2:35pm UTC](https://forums.suse.com/t/use-api-to-add-custom-catalog/2324 "2016-04-05T14:35:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsvmacdonald](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@dsvmacdonald](https://forums.suse.com/u/dsvmacdonald)\
**Post date:** [April 5, 2016, 2:35pm UTC](https://forums.suse.com/t/use-api-to-add-custom-catalog/2324/1 "2016-04-05T14:35:57Z")

</div>

Does anybody know if it is possible to add a custom catalog using Rancher’s API? I currently have scripts that use the API to create and configure a local Rancher instance with API Tokens and registries (DockerHub and Artifactory). I would also like to add in our custom Rancher Catalog.

Thanks,

Dan

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [April 5, 2016, 11:10pm UTC](https://forums.suse.com/t/use-api-to-add-custom-catalog/2324/2 "2016-04-05T23:10:33Z")

</div>

The UI is entirely driven by the API. The catalog list is a setting with a comma-separated list of key/value (`name`=`url`) pairs.

You can GET the current value: `GET /v1/settings/catalog.url`

And then update the list with a new value: `PUT /v1/settings/catalog.url` `{value: 'name1=url1, name2=url2'}`

---

<div class="post-metadata">

**Author:** ![dsvmacdonald](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@dsvmacdonald](https://forums.suse.com/u/dsvmacdonald)\
**Post date:** [April 7, 2016, 11:08am UTC](https://forums.suse.com/t/use-api-to-add-custom-catalog/2324/3 "2016-04-07T11:08:37Z")

</div>

I tried your suggestion using the following request I generated thru the API Browser but I got a “Method not allowed” error.

> curl -u “D58E321A5A05680BF71C:WdnmhXsj3MaqtY7T6YFpCY2TYeAvYk3fHPSLeCMf”   
> -X PUT   
> -H ‘Accept: application/json’   
> -H ‘Content-Type: application/json’   
> -d ‘{“activeValue”:“library=[GitHub - rancher/rancher-catalog](https://github.com/rancher/rancher-catalog.git), community=[GitHub - rancher/community-catalog: Catalog entries contributed by the community](https://github.com/rancher/community-catalog.git)”, “id”:“1as!catalog.url”, “name”:“catalog.url”, “source”:“Default Environment Variables”, “value”:“library=[GitHub - rancher/rancher-catalog](https://github.com/rancher/rancher-catalog.git), community=[GitHub - rancher/community-catalog: Catalog entries contributed by the community](https://github.com/rancher/community-catalog.git)”}’   
> ‘[http://192.168.101.128:8080/v1/activesettings/1as!catalog.url](http://192.168.101.128:8080/v1/activesettings/1as!catalog.url)’

Error:

> {“id”:“0884ac22-ad11-404a-a581-2a444ff81e44”,“type”:“error”,“links”:{},“actions”:{},“status”:405,“code”:“Method not allowed”,“message”:“Method not allowed”,“detail”:null}{“id”:“91437d43-1bb5-438a-955c-c580b2cdc394”,“type”:“error”,“links”:{},“actions”:{},“status”:405,“code”:“Method not allowed”,“message”:“Method not allowed”,“detail”:null}

It seems the API token I’m using for default environment does not work with settings. I have not yet enabled any authentication. How can I generate a key pair that will work against /v1/activesettings?

---

<div class="post-metadata">

**Author:** ![dsvmacdonald](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@dsvmacdonald](https://forums.suse.com/u/dsvmacdonald)\
**Post date:** [April 7, 2016, 11:40am UTC](https://forums.suse.com/t/use-api-to-add-custom-catalog/2324/4 "2016-04-07T11:40:40Z")

</div>

Figured it out looking from: [forum post 1](http://forums.suse.com/t/api-spec-creating-a-new-environment-project/430) and [forum post 2](http://forums.suse.com/t/how-can-i-create-registrationtoken-resource-without-navigating-web-page/1580)

Basically need to first create an admin key with something like:

> curl -X POST   
> -H ‘Accept: application/json’   
> -H ‘Content-Type: application/json’   
> -d ‘{“accountId”:“1a1”, “description”:“Scripting administration account”, “name”:“admin”, “publicValue”:“script”}’   
> ‘[http://192.168.101.128:8080/v1/apikeys](http://192.168.101.128:8080/v1/apikeys)’

Wait till it becomes active and then add the catalog with something like:

> curl -u “admin:script”   
> -X PUT   
> -H ‘Accept: application/json’   
> -H ‘Content-Type: application/json’   
> -d ‘{“activeValue”:“library=[GitHub - rancher/rancher-catalog](https://github.com/rancher/rancher-catalog.git), community=[GitHub - rancher/community-catalog: Catalog entries contributed by the community](https://github.com/rancher/community-catalog.git)”, “id”:“1as!catalog.url”, “name”:“catalog.url”, “source”:“Default Environment Variables”, “value”:“library=[GitHub - rancher/rancher-catalog](https://github.com/rancher/rancher-catalog.git), community=[GitHub - rancher/community-catalog: Catalog entries contributed by the community](https://github.com/rancher/community-catalog.git)”, newXXX=[https://XXXXX/XXXXX.git](https://XXXXX/XXXXX.git)}’   
> ‘[http://192.168.101.128:8080/v1/activesettings/1as!catalog.url](http://192.168.101.128:8080/v1/activesettings/1as!catalog.url)’

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [April 7, 2016, 4:03pm UTC](https://forums.suse.com/t/use-api-to-add-custom-catalog/2324/5 "2016-04-07T16:03:48Z")

</div>

With access control off you don’t need to send authentication at all, but settings are global so an environment-specific apikey doesn’t have access to change them.

---

<div class="post-metadata">

**Author:** ![srinhari](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@srinhari](https://forums.suse.com/u/srinhari)\
**Post date:** [November 23, 2017, 11:29am UTC](https://forums.suse.com/t/use-api-to-add-custom-catalog/2324/6 "2017-11-23T11:29:30Z")

</div>

> [@dsvmacdonald](#):
>
> catalog

I was facing a similar problem and came across your solution and it did solve my problem. However, this only creates the catalog from the Main line of the git path. Is there a way to link a specific Branch?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [November 23, 2017, 4:56pm UTC](https://forums.suse.com/t/use-api-to-add-custom-catalog/2324/7 "2017-11-23T16:56:28Z")

</div>

There’s a newer format as JSON which has a field for branch. If you setup what you want in the UI you can just `GET /v2-beta/settings/catalog.url` to see the right value.
