Skip to main content

Problem Creating DVIRLog

DFenn-1143
Original Poster

try

{

API api = this.GetApi();

 

// Build DVIR

DVIRLog geotabDvirLog = new DVIRLog();

 

geotabDvirLog.LogType = DVIRLogType.PreTrip;

geotabDvirLog.Device = new Device(Id.Create("b3"));

geotabDvirLog.DateTime = DateTime.UtcNow;

geotabDvirLog.Driver = new User(Id.Create("b21"));

 

Group defectGroup = new Group(Id.Create("b3FD7")); //, null, "Sunbelt Vehicle Defects List");

geotabDvirLog.DefectList = defectGroup;

geotabDvirLog.DVIRDefects = new List<DVIRDefect>();

 

geotabDvirLog.IsSafeToOperate = true;

geotabDvirLog.CertifiedBy = new User(Id.Create("b21"));

geotabDvirLog.CertifyDate = DateTime.Now.ToUniversalTime();

 

DVIRLog result = api.CallAsync<DVIRLog>("Add", typeof(DVIRLog), new

{

entity = geotabDvirLog

}).Result;

}

catch (Exception ex)

{

Console.WriteLine(ex.GetBaseException().Message);

Console.WriteLine(ex.GetBaseException().ToString());

Assert.Fail(ex.Message);

}

 

Join the conversation

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

Top Answers

Hi @DFenn-1143​ ! The returned value of an Add call will always be the Id of the newly created entity according to docs:

https://developers.geotab.com/myGeotab/apiReference/methods/Add/

2 Replies

DFenn-1143
Original Poster

The below works better, IF Id is used for the return type.

Id dvirId = api.CallAsync<Id>("Add", typeof(DVIRLog), new

{

entity = geotabDvirLog

}).Result;

Hi @DFenn-1143​ ! The returned value of an Add call will always be the Id of the newly created entity according to docs:

https://developers.geotab.com/myGeotab/apiReference/methods/Add/

Still have questions?