public string ReturnKingdeeAccount()
{
string responseJson = "";
try
{
string WebAPIUrl = ReturnAppSettingValue("KingdeeAccount");
HttpContent httpContent = new StringContent("");
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpClient httpClient = new HttpClient();
HttpResponseMessage response = httpClient.PostAsync(WebAPIUrl, httpContent).Result;
if (response.IsSuccessStatusCode)
{
responseJson = response.Content.ReadAsStringAsync().Result;
responseJson=JsonConvert.DeserializeObject<string>(responseJson);
}
else
{
responseJson = "";
}
}
catch (Exception ex)
{
WriteLog(ex.Message, LogEnum.Error);
throw ex;
}
return responseJson;
}
返回的json字符串前台转换json对象可能会失败,故 上述方法最后应改为: return responseJson.Replace(
"\r\n"
,
"\\r\\n"
)