I using an API wrapper made by Axosoft for their ontime software. I was looking through their API example which demonstrates a few times how to use their api to create items (i.e var foo = axosoftClinet.Customer.Create(new Customer { //fields similar to worklogs here });
) When I tried the other create method they worked flawlessly Now I'm stuck. I'm getting a NullReferenceException in my code. After reading the stack overflow question here I think it my be do to not have WorkLog initialized.
When I start writing the call it get this helper text.
Result<WorkLog> ICreateResource<WorkLog>.Create(Worklog entity, [IDictionary<string,object> parameters = null})
The helper text is identical to all the other items I can use .Create. I never seen the other examples use the IDictorynary.
So my question is how would I initialize WorkLog to avoid the NullRefenceException?
DateTime? wlDateTime = Datetime.Now;
var worklogpost = axosoftClient.WorkLogs.Create(new WorkLog
{
Item =
{
ItemType = "defects",
Id = 31
},
WorkDone =
{
Duration = 2,
TimeUnit =
{
Id = 2
},
},
User =
{
Id = 100
},
WorklogType =
{
Id = 1
},
Description = "created a worklog from the code.",
DateTime = wlDateTime,
});