webappi로 전달되는 json 문자열이 있는데, 이제 문제는 특수 문자를 추가하려고하면 수신 객체가 null이됩니다.특수 문자를 사용하여 WebApi에 json 데이터를 전달하면 null이됩니다.
여기에 나와 있습니다.
"{\"Firstname\":\"kyv®\",\"Lastname\":\"sab®\"}"
나는 그것이 문제를 해결할 것으로 기대하고 헤더에이 일을 추가 한 :
string json = JsonConvert.SerializeObject(ojectParams);
WebClient client = new WebClient();
client.Headers.Add("content-type", "application/json; charset=utf-8");
client.Headers.Add("AppKey", WebUser.AppKey);
client.Headers.Add("AppSecret", WebUser.AppSecret);
client.Headers.Add("AccountId", WebUser.AccountId.ToString());
if (!string.IsNullOrEmpty(WebUser.StoreId))
{
client.Headers.Add("StoreId", WebUser.StoreId);
}
var returnedStringObject = client.UploadString(string.Format("{0}/{1}", ConfigurationManager.AppSettings["Api"], endpoint), method, json);
다음은 JSON 문자열입니다. 그러나 운이 없다.
charset=utf-8
수신 끝점에서 obj가 null이됩니다. 그러나 특수 문자를 제거하면 값이 전달됩니다.
[HttpPost]
public responseObj Endpoint(requestObj request)
아이디어가 있으십니까? 감사!
가능한 중복의
http://stackoverflow.com/questions/ 12081382/post-values-are-not-web-api의 특수 문자로 인해) – joelmdev참고로이 게시물은 비동기 업로드를 사용하고 있습니다. 내 것이 아니야. 나는 그것이 그대로 있기를 원한다. – ljpv14
모델 상태 유효성을 검사하여 오류가 있는지 확인하십시오. –