-1

I got a Web-Api project. This project is rolled out on a kestrel as a service. Now one of all my endpoints returns straight a 500, the others work fine. And the 500 I get only on kestrel, also while using kestrel local for debugging.

I empty my controller (code inside the controller class), simplified like code below. I tried changing the name. This all makes no difference. And the controller looks the same than other controller classes.

I know, it is a hard question, but where could I look for the solution of this problem that I get always a 500 response straight away?

Frank

namespace DataPicker.Api.Controllers
{
  [Produces("application/json")]
  [Route("api/v1/dataPicker/environmentData")]
  public class TimeSeriesController : Controller
  {
    public TimeSeriesController(){}

    [HttpPost()]
    public async Task<IActionResult> 
    CreateAsync([FromBody]Data data)
    {
        return Ok("received");
    }

    public class Data
    {
        [JsonProperty("text", Required = Required.AllowNull)]
        public string Text { get; set; }
    }
  }
}

Curl: curl -X POST "http://localhost:5000/api/v1/dataPicker/environmentData" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"text\": \"string\"}"

Response: 500, Error: Internal Server Error Response headers content-length: 0 date: Mon, 17 Jun 2019 16:18:24 GMT server: Kestrel

Frank Mehlhop
  • 1,480
  • 4
  • 25
  • 48

1 Answers1

0

I don't understand how the solution fits to the problem but I got it working through setting the url's in a different way than before:

launchSettings.json:

"Kestrel": {
  "commandName": "Project",
  "launchBrowser": true,
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  },
  "applicationUrl": "http://localhost:5000/"
}

Programm.cs:

        public static IWebHostBuilder BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .UseApplicationInsights()
            .UseUrls("http://0.0.0.0:5000")
            .UseKestrel();
Frank Mehlhop
  • 1,480
  • 4
  • 25
  • 48