当我尝试发送请求时,我得到一个“内部错误”异常,所以我想知道问题是否出在我的特定请求中,或者是否还有其他问题。
cUrl 请求如下所示:
curl https://(canvas_api_url)?access_token=(access-token)
-X 发布
-F '注册[user_id]=241'
-F '注册[类型]=学生注册'
我的请求如下所示:
HttpWebRequest req = WebRequest.Create("https://<canvas_api_url>?access_token=<access-token>");
req.Method = "POST";
req.ContentType = " application/json; charset=utf-8";
req.UseDefaultCredentials = true;
req.PreAuthenticate = true;
req.Credentials = CredentialCache.DefaultCredential;
using (var streamWriter = new StreamWriter(req.GetRequestStream())
{
string json = "{\"enrollment\" :
[\"user_id\" : \"241\", \"type\" : \"StudentEnrollment\"]}";
streamWriter.Write(json);
}
HttpWebResponse response = req.GetResponse();
我的请求有问题吗?