简体   繁体   中英

Web Api response error for get request - System.Reflection.TargetInvocationException - 500 internal server error

When I debug it using Postman, it could invoke the Web Api method. The controller is scaffolded using option "Web Api 2 Controller with actions, using Entity Framework" in .NET Framework 4.6.1, Web Application Web, Api project.

// GET: api/MovieHallDetails
public IQueryable<MovieHallDetails> GetMovieHallDetails() { 
        return db.MovieHallDetails;
}

These are the sample data in the table when I select it with SQL select query:

Id  MovieHallId Seats   SeatStatus
297 9           1,1     0
298 9           1,2     0
299 9           1,3     0
300 9           1,4     0

I also have many other similar Web Api methods for other tables and I could issues get request and able to get the successful web api response except for this one.

These is what return back when I test it at Postman

500 internal server error

Blockquote

The MovieHallDetails does not have parameterless constructor. After added parameterles constructor, problem solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM