コンテンツから特定の値を取得しようとしていますが、どうすればいいのかわかりません。Restsharpがコンテンツから特定のJSON値を取得する
RestSharp(C#)を使用してJSONコードを実行していますが、コマンドを実行するとエラーが返されます。私は、プロパティerrorMessageから値を取得する必要があります。
var json = JsonConvert.SerializeObject(objectToUpdate);
var request = new RestRequest(Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddCookie("authToken", token);
request.AddParameter("application/json", json, ParameterType.RequestBody);
var response = client.Execute<T>(request);
After execute this code my response return the below JSON:
{
"response":{},
"status":{
"success":false,
"detail":{
"errormessage":[{
"fieldName":"departmentCode",
"errorMessage":"Department code provided is already associated with another department",
"errorCode":"DUPLICATE_DEPARTMENT_CODE"
}],
"error":"Validation failure on request",
"operation":"internal",
"errorcode":"412"
}
}
}
try "request.Parameters.Clear();" before "request.AddCookie(" authToken "、token);" –
はhttps://stackoverflow.com/questions/11400879/how-to-post-request-using-restsharpを見ているかもしれません。あなたのメッセージがバリデーションに失敗したことを示すエラーメッセージ - departmentCodeにコンテンツの問題があります – Vladimir
こんにちは@DarkoMaricProgramer、私はパラメータに問題はありません、私は** errorMessage **から情報を取得する必要がありますログ。 –