Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Could not get any response" in Postman

I am learning ASP.NET Core. The server I am using for this purpose is Postman, which I import a JSON file to from disc. The code for the API is written in Visual Studio and is compiled error-free. When I send a GET request in Postman, I get this error: "Could not get any response". To solve this I made changes in the setting (see the attached images), but it was not the solution. Could you please me with this? enter image description here enter image description here

This is an screenshot showing the GET request and the error I get:enter image description here

The code for the Controller:

using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CityInfo.API.Controllers
{
    [Route("api/cities")]
    public class CitiesController : Controller
    {
        [HttpGet()]
        public IActionResult GetCities()
        {
            return Ok(CitiesDataStore.Current.Cities);
        }

        [HttpGet("{id}")]
        public IActionResult GetCity(int id)
        {
            var cityToReturn = CitiesDataStore.Current.Cities.FirstOrDefault(c => c.Id == id);
            //);
            if (cityToReturn == null)
                return NotFound();
            else
                return Ok(cityToReturn);
        }
    }
}
like image 211
Alpha Bravo Charlie ... Avatar asked Oct 15 '18 15:10

Alpha Bravo Charlie ...


1 Answers

I was having the same problem. It is my first time using asp net core to build a web api and was struggling with this same issue.

I've solved this way:

use dotnet dev-certs https --trust to build the certificate. Then use dotnet run

To fix in postman go to the Settings -> General and turn off SSL certificate verification.

Hope it helps you.

Found out the answer in this video: ASP .NET Core - Fix Problem Postman cannot access due to SSL Certificate Error by CMVDev

like image 86
luturol Avatar answered Sep 19 '22 12:09

luturol