-1

この verb-type で content-body を送信できないというエラーが表示されます。C# VSTO デスクトップ アプリケーションから GET エンドポイントを呼び出しています。私は何を間違っていますか。

public static string GetCentralPath(LicenseMachineValidateRequestDTO licenseMachine)
{
    using (var client = new HttpClient())
    {
        client.DefaultRequestHeaders.Authorization =    new AuthenticationHeaderValue("Bearer", Properties.Settings.Default.Properties["JWT"].DefaultValue.ToString());
        var request = new HttpRequestMessage
        {
            Method = HttpMethod.Get,
            RequestUri = new Uri($"{Constants.URL.APIBase}licensemachine/GetCentralPath"),
            Content = new StringContent(JsonConvert.SerializeObject(licenseMachine), Encoding.UTF8, "application/json"),
        };
        
        using (HttpResponseMessage response = client.SendAsync(request).GetAwaiter().GetResult()) // Causing ERROR
        {
            var result = GetStringResultFromHttpResponseMessage(response, true);
            if (string.IsNullOrEmpty(result))
                return null;
            return JsonConvert.DeserializeObject<string>(result);
        }
    }
}

エンドポイントは次のようになります。

[HttpGet("GetCentralPath")]
public async Task<IActionResult> GetCentralPath(LicenseMachineValidateRequestDTO dto)
{
    // Some code
}
4

1 に答える 1