I have the following code:
namespace TwilioSendMessages.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class SMSController : ControllerBase
{
private readonly IWebHostEnvironment _webHostEnvironment;
public readonly IConfiguration _configuration;
private readonly ITwilioRestClient _client;
public SMSController(IWebHostEnvironment webHostEnvironment, IConfiguration configuration, ITwilioRestClient client)
{
_webHostEnvironment = webHostEnvironment;
_configuration = configuration;
_client = client;
}
[Route("SendSMS")]
[HttpPost]
public IActionResult SendSMS(SmsMessage model)
{
var message = MessageResource.Create(
to: new PhoneNumber(model.To),
from: new PhoneNumber(model.From),
body: model.Message,
client: _client); // pass in the custom client
return Ok("Success");
}
}
}
when i tried to call the api on my local machine like this:
https://localhost:7262/api/SMS/SendSMS
its says page is not working. I also tried calling the api this way. I get the same message saying page is not working:
https://localhost:7262/api/SMSController
When I run the code directly. This page comes up and I can type "To" , "From" and "Message" and it works. How can I call this API using the URL on my local machine.