# Deploy Workload via REST API Example

**URL:** <https://forums.suse.com/t/deploy-workload-via-rest-api-example/10745>\
**Category:** SUSE Rancher Prime\
**Created:** [June 13, 2018, 12:33am UTC](https://forums.suse.com/t/deploy-workload-via-rest-api-example/10745 "2018-06-13T00:33:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![slartibastfast](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/slartibastfast/32/3883_2.png) [@slartibastfast](https://forums.suse.com/u/slartibastfast)\
**Post date:** [June 13, 2018, 12:33am UTC](https://forums.suse.com/t/deploy-workload-via-rest-api-example/10745/1 "2018-06-13T00:33:57Z")

</div>

I would like to deploy a workload on Rancher 2.x using the REST API. Can anyone share a working example for this?

Thanks!

---

<div class="post-metadata">

**Author:** ![antwan2093](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/antwan2093/32/4201_2.png) [@antwan2093](https://forums.suse.com/u/antwan2093)\
**Post date:** [June 20, 2018, 7:51pm UTC](https://forums.suse.com/t/deploy-workload-via-rest-api-example/10745/2 "2018-06-20T19:51:47Z")

</div>

Hi, did you find a solution to this? I’m sure others are curious too.

I’m ideally looking to deploy helm charts, but not sure if this is best done over the REST API or simply using a helm client sdk on my application side.

---

<div class="post-metadata">

**Author:** ![slartibastfast](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/slartibastfast/32/3883_2.png) [@slartibastfast](https://forums.suse.com/u/slartibastfast)\
**Post date:** [June 21, 2018, 1:18am UTC](https://forums.suse.com/t/deploy-workload-via-rest-api-example/10745/3 "2018-06-21T01:18:46Z")

</div>

Hi, sorry so far I haven’t found a solution although the Rancher team did offer to submit the question for the last Rancher training with Jason van Brackel, I have yet to review the training video to see if it’s been answered. If not I was planning to use web UI or Rancher CLI to submit tasks and capture the network communications to the Rancher Server to work out the REST API calls. If I’m successful with this I will post the results over the coming week. Hope this helps.

---

<div class="post-metadata">

**Author:** ![antwan2093](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/antwan2093/32/4201_2.png) [@antwan2093](https://forums.suse.com/u/antwan2093)\
**Post date:** [June 24, 2018, 11:09am UTC](https://forums.suse.com/t/deploy-workload-via-rest-api-example/10745/4 "2018-06-24T11:09:54Z")

</div>

Hey, thanks for the reply. Yeah i’ve been successful with the UI, think i’ll do the same, investigate network logs and unpick it! Will try to document this for anyone else who is interested.

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![new\_ca\_grower](https://avatars.discourse-cdn.com/v4/letter/n/258eb7/32.png) [@new\_ca\_grower](https://forums.suse.com/u/new_ca_grower)\
**Post date:** [July 5, 2018, 5:29pm UTC](https://forums.suse.com/t/deploy-workload-via-rest-api-example/10745/5 "2018-07-05T17:29:11Z")

</div>

Hi antwan2093,

Did you have any luck figuring out how to update workloads via the Rancher 2 REST API?

---

<div class="post-metadata">

**Author:** ![mkuendig](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mkuendig](https://forums.suse.com/u/mkuendig)\
**Post date:** [November 12, 2018, 8:26am UTC](https://forums.suse.com/t/deploy-workload-via-rest-api-example/10745/6 "2018-11-12T08:26:15Z")

</div>

This python script works for me:

```
import requests

ACCESS_KEY = 'apiAccessKey'
ACCESS_SECRET = 'apiAccessSecret'
config = {
    "containers": [{
        "imagePullPolicy": "IfNotPresent",
        "image": "nginx",
        "name": "nginx-test",
    }],
    "namespaceId": "test-namespace",
    "name": "nginx-test"
}

requests.post('https://rancher2.example.com/v3/project/c-dwbgf:y-cfkx1/workloads', json=config, auth=(ACCESS_KEY, ACCESS_SECRET)
```
