I encountered an issue with the date input stating, "The parameters dictionary includes a missing value for 'Fromdate' parameter, which is of non-nullable type 'System.DateTime'."

An error message is popping up that says: '{"Message":"The request is invalid.","MessageDetail":"The parameters dictionary contains a null entry for parameter 'Fromdate' of non-nullable type 'System.DateTime' for method 'System.Net.Http.HttpResponseMessage CustomerWiseQuotationHistory(Int64, System.String, System.DateTime, System.DateTime)' in 'shenoyapi.Controllers.ReportController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter."}'

Here is the Component.ts code:

 validate(): boolean {
    this.appErrors = [];

    if (this.objProductQuotationHistory.ProductName=='') {
      this.appErrors.push({ Title: 'Select Product Name.' });
    }

    if (this.objProductQuotationHistory.FromDate > this.objProductQuotationHistory.ToDate) {
      this.appErrors.push({ Title: 'From Date date cannot be greater than To Date.' });
    }
    if (this.appErrors.length > 0) {
      return false;
    }
    else {
        return true;
      }
    }

 print(type: string ): void {
    if (!this.validate()) {
      const dialogRef = this.dialog.open(AlertdialogComponent, { data: this.appErrors });
      return;
    }

And here is the services.ts code:

 getProductHistory(productId: number,FromDate: Date,ToDate:Date): Observable<number>{
    let f = moment(FromDate);
    let fromdate = f.format('YYYY-MM-DD');
    let t = moment(ToDate);
    let todate = t.format('YYYY-MM-DD');

    return this.http.get<number>(AppConfig.BASE_API_URL +'/api/report/productwisequotationhistoryreport/' + productId + '/' + fromdate + '/' + todate);

  }

This snippet shows the API:

 [Route("api/report/productwisequotationhistoryreport/{id}/{type}/{Fromdate}/{ToDate}")]
        [HttpGet]
        public HttpResponseMessage ProductrWiseQuotationHistory(long id, string type, DateTime Fromdate, DateTime ToDate)
        {
            try
            {

                // Code block for processing and generating report

                return response;
            }
            catch (Exception ee)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, ee.Message));
            }

Answer №1

retrieveProductPast(productId: number,startDate: Date,endDate: Date)

Rename startDate and endDate variables in your code. Your IDE might be suggesting they are types. Ensure you have imported all necessary libraries. Also, remember to perform parameter validation for these dates in the retrieveProductPast method as they could potentially be null.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountered an issue when trying to deserialize the current JSON object while submitting relational data

I have encountered a problem while trying to add a worker to a job, specifically when dealing with the ModelState check. Here are the steps I've taken: Filling out the form Upon submitting the form, I checked the console and found: Name = "test", ...

Sending an image in the body of an HTTP request using Angular 7

I'm currently in the process of developing an Angular application that captures an image from a webcam every second and sends it to a REST API endpoint for analysis. To achieve this, I have implemented an interval observable that captures video from t ...

Is there a way to reveal only the version information from the package.json file in an Angular 17 project?

Is there a secure way to extract and display only the version from a package.json file on the UI of a web application without exposing the rest of its contents? I am currently using the following structure in my package.json: { "name": "exa ...

Displaying JSON data in a table using Angular 4

Here is a JSON data example: { "0": { "open": 93.3, "high": 96, "low": 93.3, "close": 95.04, "volume": 358172, "score": "100", "symbol": "ZBRA", "company_name": "Zebra Technologies Corp.", "company_sector": "Industrial Goods" }, "1": { "open": 19.1396, "h ...

Determine if the "type" field is optional or mandatory for the specified input fields in Typescript

I need to determine whether the fields of a typescript type or interface are optional or required. export type Recommendation = { id?: string, name: string, type?: string, tt: string, isin?: string, issuer: string, quantity?: nu ...

When Utilizing an async Task Method, DbContext is Properly Disposed

Currently, I have set up an async Task method to handle the IAuthenticationFilter interface. After logging in successfully, I can access an API with no issues when it has this attribute. However, if I revisit the API later on, an exception is thrown. publ ...

Is it possible for me to generate typing/declaration (.d.ts) and decorator metadata (.metadata.json) files with the help of @ngtools/webpack?

Currently, I am in the process of updating an Angular library to be compatible with AOT compilation. To achieve this, I have set up some gulp tasks using ngc. However, I am considering switching to @ngtools/webpack as it provides a more convenient way fo ...

Angular text input with customizable placeholder text and embedded icon

Hey there, I'm looking to create a unique custom textbox that includes a text placeholder and a help icon that will display useful information in a popover. https://i.sstatic.net/Zh0IK.png When typing into the input, the textbox should have a specif ...

Encountered an error while trying to retrieve data from

Having trouble with file uploads to the S3 bucket using @aws-sdk/client-s3 library and encountering errors when uploading files larger than 70kbps: `TypeError: Failed to fetch at FetchHttpHandler.handle (fetch-http-handler.js:56:13) at PutObjectCommand ...

Filtering function that works without specific knowledge of keys

I'm working on a JavaScript method to filter a list dynamically without knowing the specific key (s). I've made some progress, but I'm stuck and not sure how to proceed. The foreach loop I have isn't correct, but I used it for clarity. ...

Tips for confirming schedule accuracy

Trying to determine if a specific time falls between two others is the task at hand. Allow me to illustrate: Presently, it's Thursday, and the time reads 11:39 PM. Establishment X operates from 12:00 AM to 11:59 PM on Thursdays (a regular occurrence ...

Attempting to transpile JavaScript or TypeScript files for compatibility within a Node environment

Our node environment requires that our JavaScript files undergo Babel processing. Figuring out how to handle this has been manageable. The challenge lies in the fact that we have a mix of file types including .js, .jsx, .ts, and .tsx, which is not subject ...

An instance of an abstract class in DI, using Angular version 5

I have multiple components that require three services to be injected simultaneously with the same instance. After that, I need to create a new instance of my class for injecting the services repeatedly. My initial idea was to design an abstract class and ...

Upon completion of a promise in an express middleware and breaking out of a loop, a 404 error is returned

In my efforts to retrieve an array of object (car) from express using database functions in conjunction with the stolenCarDb object, everything seems to be working fine. However, when attempting the following code snippet, it results in a 404 error w ...

Error messages encountered following the latest update to the subsequent project

Recently, I upgraded a Next project from version 12 to 14, and now I'm encountering numerous import errors when attempting to run the project locally. There are too many errors to list completely, but here are a few examples: Import trace for requeste ...

Issues arise when attempting to read data from a JSON file upon refreshing the Angular page

Currently, I am working on an Angular application where the client has requested to have the path of the backend stored in a JSON file. This will allow them to easily modify the path without requiring another deployment. I have implemented this feature su ...

Please optimize this method to decrease its Cognitive Complexity from 21 to the maximum allowed limit of 15. What are some strategies for refactoring and simplifying the

How can I simplify this code to reduce its complexity? Sonarqube is flagging the error---> Refactor this method to reduce its Cognitive Complexity from 21 to the allowed 15. this.deviceDetails = this.data && {...this.data.deviceInfo} || {}; if (th ...

Multi-line D3 chart that dynamically updates and intersects with the axis

I am attempting to create a multiline d3 chart that can be updated with new datasets. I have developed a method to plot the new data on the existing d3 frame, but I am encountering issues when trying to update the chart with mocked data. The new data is no ...

Merge the Angular JS project with the Web Api project

In my current Play project, I have integrated an Angular Front-end using Gulp. Now, I am looking to reuse the angular code in a .Net Web-Api project. Separating APP and API into different projects may work, but to avoid issues with ports and CORS, the best ...

Could I potentially pause and wait for a subscription in Angular?

I'm looking to display a list of posts similar to this: Post List In order to indicate which post is favorited by a user, I need to retrieve data from two different collections in my MongoDB database. The ngOnInit function in my post-list.component.t ...