Removed FromBody
This commit is contained in:
@ -30,9 +30,24 @@ public partial class InboundController : ControllerBase, IInboundController<IAct
|
||||
_MetrologyRepository = metrologyRepository;
|
||||
}
|
||||
|
||||
private static JToken GetJToken(Stream stream)
|
||||
{
|
||||
JToken jsonbody;
|
||||
if (!stream.CanRead)
|
||||
jsonbody = JToken.Parse("{}");
|
||||
else
|
||||
{
|
||||
if (stream.CanSeek)
|
||||
_ = stream.Seek(0, SeekOrigin.Begin);
|
||||
string json = new StreamReader(stream).ReadToEnd();
|
||||
jsonbody = JToken.Parse(json);
|
||||
}
|
||||
return jsonbody;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("{tooltype}")]
|
||||
public IActionResult Post(string tooltype, [FromBody] JToken jsonbody)
|
||||
public IActionResult Post(string tooltype)
|
||||
{
|
||||
IPAddress? remoteIP = HttpContext.Connection.RemoteIpAddress;
|
||||
if (!_InboundRepository.IsIPAddressAllowed(_AppSettings.InboundApiAllowedIPList, remoteIP))
|
||||
@ -42,18 +57,7 @@ public partial class InboundController : ControllerBase, IInboundController<IAct
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jsonbody is null || !jsonbody.Any())
|
||||
{
|
||||
if (!Request.Body.CanRead)
|
||||
jsonbody = JToken.Parse("{}");
|
||||
else
|
||||
{
|
||||
using Stream stream = Request.Body;
|
||||
_ = stream.Seek(0, SeekOrigin.Begin);
|
||||
string json = new StreamReader(stream).ReadToEnd();
|
||||
jsonbody = JToken.Parse(json);
|
||||
}
|
||||
}
|
||||
JToken jsonbody = GetJToken(Request.Body);
|
||||
DataResponse dataResponse = _InboundRepository.Data(_MetrologyRepository, _InboundDataService, tooltype, jsonbody);
|
||||
if (!dataResponse.Errors.Any())
|
||||
return Ok(dataResponse);
|
||||
|
Reference in New Issue
Block a user