# REST API get list of device ID's from deployment

**URL:** <https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391>\
**Category:** General Discussions\
**Created:** [September 4, 2020, 8:28pm UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391 "2020-09-04T20:28:43Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [September 4, 2020, 8:28pm UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/1 "2020-09-04T20:28:43Z")

</div>

Hi,

I’m plying with server REST API and I’m trying to get list of devices for deployment. I first list deployments and then try to get list of ID’s per device. I’m getting this log (golang):

```auto
INFO[0001] deployment:{2020-09-04 20:13:17.053 +0000 UTC pending deployment-4ab9b817-7fcf-4517-a8a9-d2e10c1f4c14 release-7.2 763f1fbe-2006-40fe-9c91-fd4cf85433b4 0001-01-01 00:00:00 +0000 UTC 2 0} module=client
DEBU[0001] sending request: 
GET /api/management/v1/deployments/deployments/763f1fbe-2006-40fe-9c91-fd4cf85433b4/device_list HTTP/1.1
Host: mendertest.mydomain.com
Authorization: Bearer XXXXXXXXX
DEBU[0001] response: 
HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Fri, 04 Sep 2020 20:16:06 GMT
Server: openresty/1.13.6.2
Vary: Accept-Encoding
X-Deployments-Version: unknown
X-Men-Requestid: 584b509b-afb4-4b3a-b882-25a1711373a5

{"Error":"Resource not found"} module=mender

```

I double check paths and ID’s and it seems to be correct. First line is printed actual deployment. I’m using mender server v2.1.1. Any ideas what I’m doing wrong? Thanks.

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [September 10, 2020, 9:22am UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/2 "2020-09-10T09:22:54Z")

</div>

I do not see anything wrong with the API call. Are you sure the deployment id exists?

Maybe you can run and print this one first:

```auto
api/management/v1/deployments/deployments

```

@peter @tranchitella, anything to add?

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [September 10, 2020, 9:25am UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/3 "2020-09-10T09:25:10Z")

</div>

I do see that there are two different ids in your first print:

```auto
deployment-4ab9b817-7fcf-4517-a8a9-d2e10c1f4c14
763f1fbe-2006-40fe-9c91-fd4cf85433b4

```

You seem to be using the second one? This could actually just be the request ID, and I suspect the first one is the actual deployment ID

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [September 10, 2020, 9:27am UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/4 "2020-09-10T09:27:09Z")

</div>

`deployment-4ab9b817-7fcf-4517-a8a9-d2e10c1f4c14` is deployment name generated by test + uuid. Actually `763f1fbe-2006-40fe-9c91-fd4cf85433b4` is deployment ID which I used also in request.

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [September 10, 2020, 9:43am UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/5 "2020-09-10T09:43:23Z")

</div>

Better visible here:

```auto
INFO[0001] deployment:{
	"created": "2020-09-10T09:41:25.049Z",
	"status": "pending",
	"name": "deployment-235926fa-e7aa-43d8-80b4-962b223f350b",
	"artifact_name": "release-2.6",
	"id": "938cd4a4-58a9-47b7-8acd-0538f9b725fe",
	"finished": "0001-01-01T00:00:00Z",
	"device_count": 3,
	"retries": 0
} module=client
DEBU[0001] sending request: 
GET /api/management/v1/deployments/deployments/938cd4a4-58a9-47b7-8acd-0538f9b725fe/device_list HTTP/1.1
Host: mendertest.device.com
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MDAzMzU3MjMsImp0aSI6IjRkMzJjNjZlLWZhMzEtNGVhNS05NWNjLWJkZTllOTU4MTA1OCIsImlzcyI6Im1lbmRlci51c2VyYWRtIiwic3ViIjoiYjY2YTVmYjEtMjA4My00NTQ2LTliMWYtNjQ0NDhiNmZiZTQ1Iiwic2NwIjoibWVuZGVyLioiLCJtZW5kZXIudXNlciI6dHJ1ZX0.bqjammG50_zXJXoCnHRuTjquQHNt71cpXkDUC__ag4DtMARHgBsV5VU-R40AYCiGXr64Oo4BJSlj4dK7V8ZVEUxc17Vv01RVNCYfg_Z49wdNPQF1mgEx3-3BaKEmEt29rEJ8s7Vw7IvwYVswr89dwaWwW47bZVfZBrEb3XdpCvuo22Csc1nSq69OfepiP4SOVDhZeA2KezO2o5gEkB72qqhvYb5OyT-omCDVn2O0CvpYIaWcaVchpGOM3L1OL_UaHh0VJ2qZtoFMGqY-gn7HCRoFW24RN07o4_uny0XuuC7V_M6sSP41n3TaakB3iSMmyVcq-cudCQs1iCRcoj-DjoblNER33EVY48ZUC95FHfHlOId9IxNgKbxLR3afOrjCCSQRKGUGqmJP9ivrSYgd8qxlrIlcAY-wfkIt8nukBQUMaNKeAIOIzdBUP2vn0pRzbTvb9bzq0vBE777xfsmJ-YGml6Q6Ge6hTzNCvUN_XTn9OhriY-twx1KyzY7KIYQy
  module=mender
DEBU[0002] response: 
HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Thu, 10 Sep 2020 09:42:04 GMT
Server: openresty/1.13.6.2
Vary: Accept-Encoding
X-Deployments-Version: unknown
X-Men-Requestid: 3606ab93-9ea6-48db-b058-2e5d7df30fd8

{"Error":"Resource not found"} module=mender

```

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [September 10, 2020, 10:45am UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/6 "2020-09-10T10:45:36Z")

</div>

Hm, the “Pending” state could explain this. Until devices actually have checked in with the server to transition this deployment to “InProgress” it will not contain any devices.

@peter/@tranchitella, please correct me if I am wrong

---

<div class="post-metadata">

**Author:** ![tranchitella](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/tranchitella/32/606_2.png) [@tranchitella](https://hub.mender.io/u/tranchitella)\
**Post date:** [September 10, 2020, 12:37pm UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/7 "2020-09-10T12:37:38Z")

</div>

@mirzak is right, the status is in “pending” as long as no device checked for updated

@MarekBelisko, can you please try to call the `/deployments/{deployment_id}/statistics` end-point instead, and see if you get the statistics about the deployment?

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [September 10, 2020, 12:39pm UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/8 "2020-09-10T12:39:49Z")

</div>

@tranchitella yes I got info about statistics and also number of devices e.g. 2 but cannot get list of device. So in my flow I need to wait until state is changed to in progress and then can get list of devices right? Maybe API docu should be updated :). Thanks.

---

<div class="post-metadata">

**Author:** ![tranchitella](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/tranchitella/32/606_2.png) [@tranchitella](https://hub.mender.io/u/tranchitella)\
**Post date:** [September 10, 2020, 12:45pm UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/9 "2020-09-10T12:45:13Z")

</div>

You should be able to get the device IDs even if the deployment is pending, because that information is contained in a field of the Deployment object. The strange thing is that you receive 404 Not Found, which is not expected unless the deployment ID is wrong, that’s why I’ve asked you to consume the other end-point for statistics.

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [September 10, 2020, 12:46pm UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/10 "2020-09-10T12:46:11Z")

</div>

OK let me check and get back to you with results. Thanks.

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [September 10, 2020, 1:27pm UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/11 "2020-09-10T13:27:14Z")

</div>

OK I tried and still failure while statistics can be read out:

```auto
GET /api/management/v1/deployments/deployments/bbb29c16-b7c5-419e-8ddd-ad4dc679b2ce/statistics HTTP/1.1
Host: mendertest.device.com
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MDAzNDg4NTksImp0aSI6IjIzNTg4YzFmLWVhZjctNDlkYS05YmRmLTQ4MDRmOWE5ODY3NiIsImlzcyI6Im1lbmRlci51c2VyYWRtIiwic3ViIjoiYjY2YTVmYjEtMjA4My00NTQ2LTliMWYtNjQ0NDhiNmZiZTQ1Iiwic2NwIjoibWVuZGVyLioiLCJtZW5kZXIudXNlciI6dHJ1ZX0.Wg1xmzmkMBIc37wPWRsu37oqNfT1HbMGU2VC4avYk9d0lksMaeebE-OJbLOlxcpfcDrXhKNeYcNWO2vCLNp2IyU8wAFe3suxPU4ZRgESTZdo_ZBADMKGo8M0_cXT9a2kq49wr6oSVn0Ny1VN25oZDQvzaUOh9b_gt2qh77RdF-99DDa0a4CIsb2xbmleOM6tuS5GJfhxVae8CpaxjN2CCdD5owhgH8OSAvsDTmv55xlC0mqI_lngTuNIT3er5Fa6z0zUGxhU_7hNGEHq0nWRRN1CKKtcDYFomZeCAuofJb-bz3d2kTtgSSi75hKMZbaVeVyzjS9gk77cV7qHRePRZKCguGvS3yU4s6-YfwjU_q8j14IeX4rfJOxlg-vqjtriXjrJy9OXTqgfHgXmIInKwWSJlcUhnQMc6caorApxF8BaFWR6CB8JBEVEKEVywo-4deHNFcdhXZR7lHJq748RJijbaWfoiNTX4G6HSaRnJ_B_xGhk7s2IStMGw6XgP-bs
  module=mender
DEBU[0011] response: 
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Thu, 10 Sep 2020 13:21:10 GMT
Pragma: no-cache
Server: openresty/1.13.6.2
Strict-Transport-Security: max-age=63072000; includeSubdomains; preload
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Deployments-Version: unknown
X-Frame-Options: DENY
X-Men-Requestid: 66839b51-be97-4426-bfdf-b75e01c5feef
X-Xss-Protection: 1; mode=block

{"aborted":0,"already-installed":0,"decommissioned":0,"downloading":0,"failure":0,"installing":0,"noartifact":0,"pending":3,"rebooting":0,"success":0} module=mender

GET /api/management/v1/deployments/deployments/bbb29c16-b7c5-419e-8ddd-ad4dc679b2ce/device_list HTTP/1.1
Host: mendertest.device.com
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MDAzNDg4NTksImp0aSI6IjIzNTg4YzFmLWVhZjctNDlkYS05YmRmLTQ4MDRmOWE5ODY3NiIsImlzcyI6Im1lbmRlci51c2VyYWRtIiwic3ViIjoiYjY2YTVmYjEtMjA4My00NTQ2LTliMWYtNjQ0NDhiNmZiZTQ1Iiwic2NwIjoibWVuZGVyLioiLCJtZW5kZXIudXNlciI6dHJ1ZX0.Wg1xmzmkMBIc37wPWRsu37oqNfT1HbMGU2VC4avYk9d0lksMaeebE-OJbLOlxcpfcDrXhKNeYcNWO2vCLNp2IyU8wAFe3suxPU4ZRgESTZdo_ZBADMKGo8M0_cXT9a2kq49wr6oSVn0Ny1VN25oZDQvzaUOh9b_gt2qh77RdF-99DDa0a4CIsb2xbmleOM6tuS5GJfhxVae8CpaxjN2CCdD5owhgH8OSAvsDTmv55xlC0mqI_lngTuNIT3er5Fa6z0zUGxhU_7hNGEHq0nWRRN1CKKtcDYFomZeCAuofJb-bz3d2kTtgSSi75hKMZbaVeVyzjS9gk77cV7qHRePRZKCguGvS3yU4s6-YfwjU_q8j14IeX4rfJOxlg-vqjtriXjrJy9OXTqgfHgXmIInKwWSJlcUhnQMc6caorApxF8BaFWR6CB8JBEVEKEVywo-4deHNFcdhXZR7lHJq748RJijbaWfoiNTX4G6HSaRnJ_B_xGhk7s2IStMGw6XgP-bs
  module=mender
DEBU[0012] response: 
HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Thu, 10 Sep 2020 13:21:10 GMT
Server: openresty/1.13.6.2
Vary: Accept-Encoding
X-Deployments-Version: unknown
X-Men-Requestid: f246d16d-e67f-47b0-9e8f-c269b28285cc

{"Error":"Resource not found"} module=mender

```

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [September 14, 2020, 6:32am UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/12 "2020-09-14T06:32:12Z")

</div>

@tranchitella pls see above log. I can get deployment statistics but not list of devices. Maybe my server version is too old and it was fixed in meantime? I’m using 2.1.1 Thanks

---

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://hub.mender.io/u/peter)\
**Post date:** [October 23, 2020, 3:41pm UTC](https://hub.mender.io/t/rest-api-get-list-of-device-ids-from-deployment/2391/13 "2020-10-23T15:41:11Z")

</div>

Hey Marek,

device\_list endpoint does not exist in 2.1, please refer to the docs: [https://docs.mender.io/2.1/apis/management-apis/deployments](https://docs.mender.io/2.1/apis/management-apis/deployments)  
do you consider upgrading?

peter
