What product/components do you use and which version/fix level?
Cumulocity IoT 10.10
What are trying to achieve? Please describe in detail.
I am trying to create and register the device using a custom microservice. I am able to successfully create a new device record on the platform, register the externalId and create a new deviceRequest. But when i try to change hte status of new Device request to ACCEPTED state, i get an exception as follows
requesting the device credentials once will automatically move the status into PENDING_ACCEPTANCE.
You can request the device credentials by using the bootstrap credentials on the following endpoint: https://cumulocity.com/api/10.13.0/#operation/postDeviceCredentialsCollectionResource
You won’t receive any credentials on that request as long as the status has not been ACCEPTED.
Thanks Tristan, I was actually doing that but i had a loot again at the link you shared and i realised that i forgot to add the ROLE_DEVICE_BOOTSTRAP role to the microservice. After adding the role and trying it out again it worked fine. Thanks for the help.
NewDeviceRequests have three statuses in their lifecycle: WAITING_FOR_CONNECTION, PENDING_ACCEPTANCE, and ACCEPTED. They can only be moved linearly from one status to the next, and they are only moved upon distinct actions being performed.
After the device registration is entered in UI the NewDeviceRequest is created in status WAITING_FOR_CONNECTION
It is moved to PENDING_ACCEPTANCE when the device requests its credentials for the first time (after NDR creation). No credentials are created or transferred in this step but it is necessary to confirm that the device can connect and is using the same external ID
After that it becomes possible to accept the registration in UI which will move the NewDeviceRequest to ACCEPTED
The first time the device requests its credentials again after the NewDeviceRequest is accepted credentials are created and returned as response. After this is completed the NewDeviceRequest is removed and the credentials can never be received again.
As you can see the device bootstrap process requires interactions from both the user and the device. We usually recommend that the device periodically (with exponential back-off) requests its credentials until it has obtained them (see: https://cumulocity.com/guides/device-integration/introduction/). The users can enter device registrations of known devices at any time.