Skip to main content

Adding a Custom Device via the MyGeotab API

AHodk-1929
Original Poster

Is there a way to add a Custom Device into a database via the API? I've tried doing this using a Set:CustomDevice and get the following issue which makes me think not?

`NotSupportedException: Cannot find bridge for Geotab.Checkmate.ObjectModel.CustomDevice`

 

I see a similar error if I try to read a CustomDevice via the API too.

Join the conversation

You need to be logged in to reply to this post and participate in the Geotab Community discussions.

Top Answers

Hi @AHodk-1929​ ,

 

To add a new device to a database, you need to use the Add method. Set method is used for modifying existing entities.

CustomDevice is just derived from the base class Device.

You can use the Add Device method for all types of devices including CustomDevice.

 

image 

Please refer to the link below for some examples

https://geotab.github.io/sdk/software/dotnet-samples/

 

Let me know if you have any questions.

 

Ajay Srinivasan

Solutions Engineering Lead

 

 

 

 

5 Replies

EishiFUN
Geotabber

Hello @AHodk-1929​ 

 

Thank you for asking your question in our community. I wanted to let you know I have contacted our SDK experts for their help with this question. I will let you know what I hear from them or have one of them jump in here and answer you.

 

Thank you for your patience while we look into this. Feel free to reach out with any other questions you may have in the meantime.

 

Have a good one!

Eishi FUN

Hi @AHodk-1929​ ,

 

To add a new device to a database, you need to use the Add method. Set method is used for modifying existing entities.

CustomDevice is just derived from the base class Device.

You can use the Add Device method for all types of devices including CustomDevice.

 

image 

Please refer to the link below for some examples

https://geotab.github.io/sdk/software/dotnet-samples/

 

Let me know if you have any questions.

 

Ajay Srinivasan

Solutions Engineering Lead

 

 

 

 

AHodk-1929
Original Poster

Hi Ajay,

Thanks for getting back to me & the info you sent over.

So I'm trying the following method now (JavaScript)

await api.call('Add', { typeName: 'Device', entity: { Comment: "Testing", DeviceType: "CustomDevice", Id: "f4037aba-4d03-4482-bfe7-f73bd2f3b052", TimeZoneId: "Europe/London", ProductId: 10032 // from https://developers.geotab.com/myGeotab/guides/usingCustomTelematicsDevices#automating-tasks } });

 

Without the ProductId the request is rejected with a validation error so I have used 10032 as suggested in the docs.

But now I see the error:

Error: ArgumentException: DeviceType Geotab.Checkmate.ObjectModel.Device is not consistent with the Product ID 10032. The required type is Geotab.Checkmate.ObjectModel.CustomDevice.

 

And If I try to use typeName: 'CustomDevice' , I get back to the original error:

Cannot find bridge for Geotab.Checkmate.ObjectModel.CustomDevice

 

Many thanks,

Allan

 

 

 

 

 

Hi Allan,

 

name and serialNumber are required properties. The type of device is automatically inferred from the serialNumber. So you don't need to specify the productId.

 

If you're trying to add an untracked asset (like an equipment/trailer) you still need to pass the serialNumber property but set its value to an empty string. 

 

Example:

Adding a custom device

api.call("Add", { "typeName": "Device", entity:{ name:"mynewcustomdevice", serialNumber:"ABCXYZ123456" /* Valid custom device serial number*/ } }, function(result) { console.log("Done: ", result); }, function(e) { console.error("Failed:", e); });

Adding untracked asset

api.call("Add", { "typeName": "Device", entity:{ name:"mynewcustomdevice2, serialNumber:"" } }, function(result) { console.log("Done: ", result); }, function(e) { console.error("Failed:", e); });

I hope this helps

 

Ajay

 

 

AHodk-1929
Original Poster

Thanks Ajay, I will try this.

Still have questions?