0

I'm using, Xero sdk for my .net project(using Xero.NetStandard.OAuth2.Api;using Xero.NetStandard.OAuth2.Model.PayrollAu;)

    public XeroAuth _xeroAuth;
    public PayrollAuApi ipayrollAUApi = new PayrollAuApi(); //*************
    private Xero.NetStandard.OAuth2.Model.PayrollAu.Employee _GetEmpLeave;
   
    // get perticular Employee all data
    private async Task<Xero.NetStandard.OAuth2.Model.PayrollAu.Employee> GetEmployeeAsync(Guid 
     syncedEmpID)
    {
        var tokens = await _xeroAuth.GetXeroTokenAuthorization();
        _tenantUniqueId = tokens.Item3;
        try
        {
            return ipayrollAUApi.GetEmployeeAsync(tokens.Item1, tokens.Item2, 
             syncedEmpID).Result._Employees;
        }
        catch (Exception ex)
        {

            logging.LoggingToText(ex, await _Context.GetAssemblyInfoAsync(4));
            return null;
        }
    }

in this GetEmployeeAsync method showing casting error it look like this enter image description here

how to resolve this issue

  • That suggests that you are returning a list of employees (which will probably only contain one employee as you specify the ID), rather than an individual employee. I've done nothing with payroll so I can't offer any more detail, can you change the code to only return the first member of the list? Maybe you'll have to retrieve the list inside the function, and then separately return the first member. – droopsnoot Sep 11 '21 at 17:15
  • 1
    change your method with private async Task> GetEmployeeAsync(Guid syncedEmpID) – erdi yılmaz Sep 16 '21 at 14:39
  • Thanks @erdi yılmaz – Asanka Yaparathna Sep 16 '21 at 15:39

0 Answers0