ProvisioningServiceClient.getDeviceRegistrationState(String id) Method

Definition

Retrieve the registration status information.

This method will return the DeviceRegistrationState for the provided id. It will retrieve the correspondent deviceRegistrationState from the Device Provisioning Service, and return it in the DeviceRegistrationState object.

If the id do not exists, this method will throw ProvisioningServiceClientNotFoundException. for more exceptions that this method can throw, please see ProvisioningServiceClientExceptionManager

Sample:

The follow code will get and print the information about the deviceRegistrationState "registrationId-1".

// Registration status information.
    private static final String PROVISIONING_CONNECTION_STRING = "HostName=ContosoProvisioning.azure-devices-provisioning.net;" +
                                                                 "SharedAccessKeyName=contosoprovisioningserviceowner;" +
                                                                 "SharedAccessKey=0000000000000000000000000000000000000000000=";
    private static final String REGISTRATION_ID = "registrationId-1";

    public static void main(String[] args) throws IOException, URISyntaxException, ProvisioningServiceClientException
    {
        // Create a Device Provisioning Service Client.
        DeviceProvisioningServiceClient deviceProvisioningServiceClient =
            DeviceProvisioningServiceClient.createFromConnectionString(PROVISIONING_CONNECTION_STRING);

        // Get the deviceRegistrationState information.
        DeviceRegistrationState registrationStateResult =  deviceProvisioningServiceClient.getDeviceRegistrationState(REGISTRATION_ID);
        System.out.println(registrationStateResult.toString());
    }
    

public DeviceRegistrationState getDeviceRegistrationState(String id)
Parameters
id
String

theString that identifies the deviceRegistrationState. It cannot benull or empty.

Returns

The DeviceRegistrationState with the content of the deviceRegistrationState in the Provisioning Device Service.

Exceptions
ProvisioningServiceClientException

if the Provisioning Device Service was not able to retrieve the deviceRegistrationState information for the provided registrationId.