I am using the official API for .NET and trying to add new item in app. This code had worked once but then something changed (not in the code) and it's not working anymore. Here is the code:
{
var podio = new Podio(clientId, clientSecret);
podio.AuthenticateWithApp(appId, appSecret);
Item myNewItem = new Item();
var namefield = myNewItem.Field("applicants-name");
if (model.Name != null)
{
namefield.Value = model.Name;
}
else
{
namefield.Value = "/";
}
var jobfield = myNewItem.Field("related-job-opening");
jobfield.ItemIds = new List { model.RelatedJob };
var addressfield = myNewItem.Field("address");
if (model.Address != null)
{
addressfield.Value = model.Address;
}
else
{
addressfield.Value = "/";
}
var emailfield = myNewItem.Field("email-address");
if (model.Email != null)
{
emailfield.Value = model.Email;
}
else
{
emailfield.Value = "/";
}
if (model.Linkedin != null)
{
var embed = podio.EmbedService.AddAnEmbed(model.Linkedin);
var linkedin = myNewItem.Field("linkedin-profile2");
linkedin.AddEmbed(embed.EmbedId);
}
var phone = myNewItem.Field("contact-phone-number");
if (model.Phone != null)
{
phone.Value = model.Phone;
}
else
{
phone.Value = "/";
}
if (model.Attachment != null)
{
var fileName = Path.GetFileName(model.Attachment.FileName);
var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
model.Attachment.SaveAs(path);
string extension = Path.GetExtension(model.Attachment.FileName);
FileAttachment podioFile = podio.FileService.UploadFile(path, "user-cv" + extension);
myNewItem.FileIds = new List { podioFile.FileId };
System.IO.File.Delete(path);
int itemId = podio.ItemService.AddNewItem(appId, myNewItem);
}
else
{
int itemId = podio.ItemService.AddNewItem(appId, myNewItem);
}
return "OK";
}
}
This is the line of code where the error is thrown: int itemId = podio.ItemService.AddNewItem(appId, myNewItem);
The error says Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Cannot perform runtime binding on a null reference'
Actually an error is thrown but the item is successfully added in podio. What could be wrong?