Skip to Main Content
Cumulocity IoT Feedback Portal
Categories WebSDK
Created by Guest
Created on Jul 6, 2020

@c8y/client IdentityService.detail external ID should be URL encoded automaticaly

I am using "@c8y/client": "^1005.0.12", and recognized some small issue in IdentityService.

I have got assets which have external IDs with special characters, for example: “EG Seminarräume_435”. I used the identity API to get the identity by:

public async getIdentity(type: string, externalId: string): Promise<IIdentified> {

const identity: IExternalIdentity = {

type,

externalId

};

try {

const result = await this.identityService.detail(identity);

return result.data.managedObject;

} catch (e) {

this.log.debug(e);

}

}

However for those managed objects with special characters it was not working. Fortunately, I know the REST API and the type and external ID are URL parameters. Those must be URI encoded. So I called this function with encoded URI, like this:

const identity = await this.c8yService.getIdentity(ExternalIdTypes.DEVICE_IDENTITY_TYPE, encodeURI(externalId));

Now, it works.

Actually, I had expected that the SDK is handling this! For creating an identity, Jan Hommes agreed and I should create an ITrac ticket for that, unfortunatly i can't create itrac tickets for that reason i used Empower.

  • Attach files