I am working with ASP.net Core WebAPI and to produced API documentation I am using Swagger. Swagger successfully generate colourful documentation. But when I try to execute an api method. Always got bellow error from Swagger.
{ "error": "no response from server" }
Api Method
[Route("api/[controller]")]
[Produces("application/json")]
public sealed class AuthController : BaseApiController
{
[HttpGet]
[Route("GetByUser/{uid}/{pwd}")]
public IActionResult GetByUser(string uid, string pwd){....}
}
Note:
Swagger AppSettings
"Swagger": {
"FileName": "ApiDoument.xml",
"host": "localhost:63687"
}
Swagger Response
Curl
X GET 'http://localhost:63687/api/Auth/GetByUser/test%40gmail.com/1234'
Request URL
http://localhost:63687/api/Auth/GetByUser/test%40gmail.com/1234
Response Body
no content
Response Code
0
Response Headers
{ "error": "no response from server" }
Problem is resolve, above described error due to bellow Hash value. Swagger unable to return this type of value.
AQAAAAEAACcXdXU4rzH9EpRzS2smaRdvesNxkOQMvKld2ySuzXTNcd+1Gux6CJfV90w==
Solution:
using Newtonsoft.Json;
JsonConvert.SerializeObject(Hashvalue);
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.