Having issues with a cascading report parameter using WebServiceDataSource

1 Answer 50 Views
.NET Core DataSource WebService Report Parameters Report Viewer - HTML5 Rest Service
Joe
Top achievements
Rank 1
Joe asked on 17 Oct 2024, 02:56 PM

Hello all!

I have what feels like a very simple example of using 2 cascading parameters in a report. The first parameter is loaded with no issue but come time for the second, I get a "Response status code does not indicate success: 400 (Bad Request)".

I notice in the REST service call that it is passing hasChildParameters as false. I don't see an option to set that as true.

I've found when I run the download in designer with matching values that are expected in the parameter it retrieves without issue. This is purely a runtime issue.

Here are a few screenshots of what I have setup. Any advice is appreciated.

Controller Method

FromBody model object

BaseReportParameter

 

1 Answer, 1 is accepted

Sort by
0
Ivet
Telerik team
answered on 22 Oct 2024, 08:16 AM

Hi Joe,

Thank you for the provided screenshots they were really helpful.

In the code below I was trying to adjust the data method as in the code snippet shared on your screenshots:

 public class BaseReportParameter
 {
     public string AADUserName { get; set; }
     public string AADUserId { get; set; }
     public string DataverseEnvironment { get; set; }
 }

 public class StudentScheduleGetTeachingPeriodParameters : BaseReportParameter {
     public string[] Accounts { get; set; }
 }
 public class TeachingPeriodParameterData
 {
     public string TeachingPeriodName { get; set; }
     public string TeachingPeriodId { get; set; }
 }

 [Serializable]
 [Route("api/reports")]
 [ApiController]

 public class ReportsController : ReportsControllerBase
 {
     public ReportsController(IReportServiceConfiguration reportServiceConfiguration)
           : base(reportServiceConfiguration)
     {
     }
     [AllowAnonymous, HttpPost, Route("getTeachingPeriods")]
     public ActionResult<List<TeachingPeriodParameterData>> getTeachingPeriods([FromBody] StudentScheduleGetTeachingPeriodParameters requestBody)
     {
         return new List<TeachingPeriodParameterData>() { new TeachingPeriodParameterData() { TeachingPeriodName = "ABC Uni - Online", TeachingPeriodId = "Guid2" }, new TeachingPeriodParameterData() { TeachingPeriodName = "ABC Uni - Hybrid", TeachingPeriodId = "Guid3" } };
     }

     protected override HttpStatusCode SendMailMessage(MailMessage mailMessage)
     {
         throw new System.NotImplementedException("This method should be implemented in order to send mail messages");

         // using (var smtpClient = new SmtpClient("smtp01.mycompany.com", 25))
         // {
         //    smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
         //    smtpClient.EnableSsl = false;

         // smtpClient.Send(mailMessage);
         // }
         // return HttpStatusCode.OK;
     }
 }

I also re-created the WebServiceDataSource component as in the shared images, and the request was executed successfully:

If the same setup does not work similarly on your end and you need further assistance, could you send your report and the latest version of the code for the method that returns the data?

I hope you will test and keep us updated.

Regards,
Ivet
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
Tags
.NET Core DataSource WebService Report Parameters Report Viewer - HTML5 Rest Service
Asked by
Joe
Top achievements
Rank 1
Answers by
Ivet
Telerik team
Share this question
or