http POST를 만드는 데 문제가 있습니다. 내가 호출하는 API는 content-length
을 요청하고 있습니다. 그러나 나는 이것을 어떻게하는지 확신 할 수 없다. 여기Content.Length를 계산하십시오.
코드 나는이된다
이public static string publishClip(string instance_url, string sessionId, string clipId)
{
int trev = System.Text.ASCIIEncoding.Unicode.GetByteCount(instance_url + "/services/apexrest/DesktopClient/PublishClip/" + clipId);
WebRequest wrGETURL;
wrGETURL = WebRequest
.Create(instance_url
+ "/services/apexrest/DesktopClient/PublishClip/"
+ clipId);
wrGETURL.Method = "POST";
wrGETURL.ContentType = "application/json";
wrGETURL.ContentLength = trev;
wrGETURL.Headers.Add("Authorization", "Bearer " + sessionId);
Stream objStreamclipId = wrGETURL.GetResponse().GetResponseStream();
StreamReader objReader = new StreamReader(objStreamclipId);
return "trev";
}
사람이 제발 도와 줄래?
이
나는 오류 얻고있다 :{"You must provide a request body if you set ContentLength>0 or SendChunked==true. Do this by calling [Begin]GetRequestStream before [Begin]GetResponse."}
구체적으로 작성하십시오. 'ContentLength' 속성을 설정하려고 시도했음을 코드에서 명확하게 볼 수 있습니다. 그래서, 무엇이 문제입니까? 작동하지 않았나요? 이 예제의 문제점은 다음과 같습니다. http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.contentlength.aspx? – BartoszKP
요청에 본문이 없으므로 콘텐츠 길이가 0입니다 ... –
'ContentLength = 0'을 (를) 설정 했습니까? – christiandev