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):
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.
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.
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.
@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?
@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.
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.
@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