我是第一次使用Web API,在这里我遇到了麻烦,我想在Rest API中提出PUT请求。但是我得到的只是服务器错误代码500 以下是我的代码,请标记我的错误或更正我的代码。
string TargetUrl = BaseAPIUrl + "/devices/" + 8931088717107028617;
HttpClient client = new HttpClient();
var byteArray = Encoding.ASCII.GetBytes(Username + ":" + APIKey);
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
string myJson = "{ \"status\": \"DEACTIVATED\" }";
HttpResponseMessage response = await client.PostAsync(TargetUrl, new StringContent(myJson))
作为响应,我收到服务器错误代码:500