我對使用RestSharp的發佈請求有問題。我有2類:RestSharp - 發佈發佈請求(操作失敗)
public class UnitToPost
{
public bool floating_point { get; set; }
public Dictionary<string, TranslationUnitToPost> translations { get; set; }
}
public class TranslationUnitToPost
{
public string name { get; set; }
}
而且我想與POST請求發送:
client = new RestClient(adresApi);
client.AddDefaultHeader("Authorization", "Bearer " + key);
IRestRequest updateProduct = new RestRequest("units", Method.POST);
ShoperModel.UnitToPost unitToPost = new ShoperModel.UnitToPost();
unitToPost.floating_point = true;
ShoperModel.TranslationUnitToPost transUnit = new ShoperModel.TranslationUnitToPost();
transUnit.name = "namename";
unitToPost.translations = new Dictionary<string, ShoperModel.TranslationUnitToPost>();
unitToPost.translations.Add("pl_PL", transUnit);
updateProduct.RequestFormat = RestSharp.DataFormat.Json;
updateProduct.AddBody(unitToPost);
IRestResponse updateProductResponse = this.client.Execute(updateProduct);
,我總是得到一個錯誤:
[RestSharp.RestResponse] = "StatusCode: InternalServerError, Content-Type: application/json, Content-Length: -1)"
Content = "{\"error\":\"server_error\",\"error_description\":\"Operation Failed\"}"
什麼是它的原因是什麼?難道是因爲我班上的字典?