# addServiceLink via API

**URL:** <https://forums.suse.com/t/addservicelink-via-api/3040>\
**Category:** Rancher 1.x\
**Created:** [June 6, 2016, 10:46pm UTC](https://forums.suse.com/t/addservicelink-via-api/3040 "2016-06-06T22:46:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Jensen](https://avatars.discourse-cdn.com/v4/letter/d/97f17d/32.png) [@Daniel\_Jensen](https://forums.suse.com/u/Daniel_Jensen)\
**Post date:** [June 6, 2016, 10:46pm UTC](https://forums.suse.com/t/addservicelink-via-api/3040/1 "2016-06-06T22:46:26Z")

</div>

So I have read through the API documentation and it seems simple enough:

[http://docs.rancher.com/rancher/latest/en/api/api-resources/service/](http://docs.rancher.com/rancher/latest/en/api/api-resources/service/)

Also used the curl request generator thing thats part of the API, but that seems to give an error.

> curl -u “${CATTLE\_ACCESS\_KEY}:${CATTLE\_SECRET\_KEY}”   
> -X POST   
> -H ‘Accept: application/json’   
> -H ‘Content-Type: application/json’   
> -d ‘{“serviceId”:“1s365”}’   
> ‘[https://rancher/v1/projects/1a5/services/1s366/?action=addservicelink](https://rancher/v1/projects/1a5/services/1s366/?action=addservicelink)’

> Error:

> {“id”:“83c11274-772b-4836-8e74-453764068073”,“type”:“error”,“links”:{},“actions”: {},“status”:422,“code”:“MissingRequired”,“message”:null,“detail”:null,“fieldName”:“serviceLink”}

So I’m pretty sure this means that the serviceLink field is required, so I tried this:

> curl -u “${CATTLE\_ACCESS\_KEY}:${CATTLE\_SECRET\_KEY}”   
> -X POST   
> -H ‘Accept: application/json’   
> -H ‘Content-Type: application/json’   
> -d ‘{“serviceLink”:“selenium-115/hub”, “serviceId”:“1s365”}’   
> ‘[https://rancher/v1/projects/1a5/services/1s366/?action=addservicelink](https://rancher/v1/projects/1a5/services/1s366/?action=addservicelink)’

> Error:

> {“id”:“7b0d6df2-f840-4471-a65d-f737e89bc34d”,“type”:“error”,“links”:{},“actions”:{},“status”:422,“code”:“MissingRequired”,“message”:null,“detail”:null,“fieldName”:“serviceId”}

I’m assuming that I’m just inputting the incorrect field types, although it wasn’t clear to me from the documentation what they should be. Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![Adaikal\_Raj](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@Adaikal\_Raj](https://forums.suse.com/u/Adaikal_Raj)\
**Post date:** [June 8, 2016, 6:08am UTC](https://forums.suse.com/t/addservicelink-via-api/3040/2 "2016-06-08T06:08:36Z")

</div>

I just sorted this out yesterday, had same problem.

curl -u “${CATTLE\_ACCESS\_KEY}:${CATTLE\_SECRET\_KEY}”   
-X POST   
-H ‘Accept: application/json’   
-H ‘Content-Type: application/json’   
-d ‘{“serviceLink”:{“name”:“appdb”, “serviceId”:“1s136”, “uuid”:“bb470c1d-9f78-43aa-86b0-e5b14a3b184f”}}’   
‘[http://rancher/v1/projects/1a5/services/1s137/?action=addservicelink](http://rancher/v1/projects/1a5/services/1s137/?action=addservicelink)’

serviceid and uuid are the IDs of service that you want to link

---

<div class="post-metadata">

**Author:** ![Daniel\_Jensen](https://avatars.discourse-cdn.com/v4/letter/d/97f17d/32.png) [@Daniel\_Jensen](https://forums.suse.com/u/Daniel_Jensen)\
**Post date:** [June 8, 2016, 4:14pm UTC](https://forums.suse.com/t/addservicelink-via-api/3040/3 "2016-06-08T16:14:58Z")

</div>

@Adaikal_Raj Thanks for the response!
