I have two web-apis
public string GetRData(string data)
{
var serialPort = new SerialPort("COM1", 9600, Parity.Even, 8, StopBits.One);
try
{
if(serialPort.IsOpen)
{
var stream = new SerialStream(serialPort);
stream.ReadTimeout = 2000;
//byte[] bytestoread = new byte[9999];
byte[] bytestosend = StringToByteArray(data);
serialPort.Write(bytestosend, 0, bytestosend.Length);
//receiveData = serialPort.ReadExisting();
serialPort.Close();
}
else
{
//serial port settings and opening it
serialPort.Open();
var stream = new SerialStream(serialPort);
stream.ReadTimeout = 2000;
//byte[] bytestoread = new byte[9999];
byte[] bytestosend = StringToByteArray(data);
serialPort.Write(bytestosend, 0, bytestosend.Length);
//receiveData = serialPort.ReadExisting();
serialPort.Close();
}
}
catch(Exception ex)
{
}
return data;
}
public string GetPData(string id)
{
var serialPort = new SerialPort("COM2", 9600, Parity.Even, 8, StopBits.One);
string receiveData = "";
try
{
//serial port settings and opening it
serialPort.Open();
var stream = new SerialStream(serialPort);
stream.ReadTimeout = 2000;
//byte[] bytestoread = new byte[9999];
//byte[] bytestosend = StringToByteArray(data);
//serialPort.Write(bytestosend, 0, bytestosend.Length);
receiveData = serialPort.ReadExisting();
serialPort.Close();
}
catch (Exception ex)
{
}
return receiveData;
}
WebApiConfig.cs
config.Routes.MapHttpRoute(
name: "GetRData",
routeTemplate: "api/{controller}/{action}/{data}",
defaults: null
);
config.Routes.MapHttpRoute(
name: "GetPData",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
Whenever I am trying to hit the GetPData
I am getting below response in Postman
{ "Message": "No HTTP resource was found that matches the request URI 'https://localhost:44337/api/rtu/GetPData/1'.", "MessageDetail": "No action was found on the controller 'RTU' that matches the request." }
I have searched for this issue but unable to get a solution.
Note: The GetRData
is working perfectly