Problem loading remote data via webapi adaptor into dropdown list in a grid

1) The dropdown list

  <GridColumn Field="ApplicationRoleDto.Name" HeaderText="Role">
      <EditTemplate>
          <SfDropDownList Placeholder="Select Role" TItem="ApplicationRoleDto" TValue="string">
              <SfDataManager Url=@($"api/v1/users/odata/roles")
                  Adaptor="Syncfusion.Blazor.Adaptors.WebApiAdaptor"
                  HttpClientInstance=@(_hc.CreateClient("App"))>
              </SfDataManager>
              <DropDownListFieldSettings Text="Name" Value="Id" />
              <DropDownListEvents TValue="string" TItem="ApplicationRoleDto"
                  OnActionComplete="@((args) => OnDropdownActionComplete(args))"
                  OnActionFailure="@((args) => OnDropdownActionFailure(args))" />
          </SfDropDownList>
      </EditTemplate>
  </GridColumn>

2)

public record ApplicationRoleDto
{
   [Required]
   publicstring?Id{get;set;}
   [Required]
   publicstring?Name{get;set;}
}




3)Api return data like

return new{Items= data,Count= recordCount };




4) example of data being returned

{
  "Items":[
    {
      "Id":"1916ca8e-0c68-47b6-8d4b-6a9f6437bd82",
      "Name":"Customer"
    },
    {
      "Id":"fcf43946-c5ff-4f4b-8c53-37156d397dc8",
      "Name":"Admin"
    },
    {
      "Id":"347f53da-50b5-461b-a5af-2e853e09b14e",
      "Name":"Employee"
    }
  ],
  "Count":3
}




5)Error that is being caught in the OnActionFailureof the dropdown list

The JSON value could not be converted to System.Collections.Generic.List`1[AppLib.Dto.ApplicationRoleDto]. Path: $ | LineNumber: 0 | BytePositionInLine: 1.


Where am I going wrong? The dropdown does not display the data returned from the api, and says no records found, where if i past the api URL directly in the browser I can see that data is in fact being returned.



1 Reply

YS Yohapuja Selvakumaran Syncfusion Team April 9, 2024 07:14 AM UTC

Hi Wuss Wuzz,


Thank you for reaching out us. We have thoroughly reviewed the reported issue based on the information provided and have also created a sample based on the shared code snippet. However, we were unable to replicate the reported issue as no exceptions occurred. Please find the sample provided below for your reference.


Sample: https://blazorplayground.syncfusion.com/hNVTDJXkBeLpQdyC





To further investigate and replicate the issue, we kindly request additional details from your end:


  1. Could you please provide details on how the failure event is triggered? Understanding the specific actions or conditions that lead to the failure event will help us better diagnose the problem.
  2. If possible, could you modify the provided sample to replicate the reported issue on our end? Alternatively, sharing the full page code snippet where the issue occurs would be helpful for us to investigate further.
  3. Additionally, if you encountered any exceptions, could you please provide details about the exception and specify which actions trigger it? Sharing a screenshot of the exception message would also be beneficial for our analysis.
  4. Could you please share the version of the Syncfusion package you are currently using? Knowing the package version will allow us to better understand the environment in which the issue is occurring and provide more targeted assistance.



Your cooperation and assistance in providing these details will greatly aid us in identifying and resolving the reported issue. Thank you for your patience and understanding.



Regards,

Yohapuja S


Loader.
Up arrow icon