I created a web API which runs perfectly on localhost.
After publishing it to Azure
POST Request returns 500 Internal Server Error
GET Request returns 200 OK
Is there something else required to do in Azure in order to make POST requests accessible and ready to be tested in Postman?
The url is https://gemcodingchallengeapi.azurewebsites.net/api/productionplan/
I used to access the api locally through https://localhost:44343/api/productionplan/
CodePudding user response:
@W.Gates provided a link that helped me solve my issue
I added the following line to in Program.cs
app.UseDeveloperExceptionPage();
I sent the POST Request and saw that the JSON I provided had an error.
After correcting the JSON format, I could successfully send POST Requests.
So by adding that line of code I knew immediately where the error was.
CodePudding user response:
I found some information that may help you. Please check the following links:
Web API works locally but doesn’t work on azure Edit: This is the link that solved the issue.
https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-rest-api This is a tutorial on How to Host a RESTful API with CORS in Azure App Service. https://github.com/Azure/azure-functions-openapi-extension/issues/122 Someone had a similar issue but with their endpoints visible locally but not when deployed on azure.
