Code: Select all
var authenticator = new JwtAuthenticator(_authService.GetToken());
var options = new RestClientOptions(Settings.Instance.CompanyURL)
{
Authenticator = authenticator
};
var client = new RestClient(options);
var request = new RestRequest("/api/MyController MyAction");
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(logData);
RestResponse response = client.Post(request);
Code: Select all
[Route("api/[controller] [action]")]
[ApiController]
public class MyController : ControllerBase
{
private IHttpContextAccessor _httpContextAccessor;
private ISaveData _saveData;
public ClientLogsController(IHttpContextAccessor httpContextAccessor, ISaveData saveData)
{
_httpContextAccessor = httpContextAccessor;
_saveData = saveData;
}
[HttpPost]
[Authorize]
public IActionResult MyAction([FromBody] string data)
{
_saveData.SaveData(data, _httpContextAccessor);
return Ok();
}
}
System.Net.Http.HttpRequestException: Anfrage fehlgeschlagen mit Statuscode BadRequest
Der Fehler stammt von der Client-App , da es von Postman aus einwandfrei funktioniert. Es fällt mir schwer herauszufinden, wo das Problem liegen könnte.