当我尝试发送请求时,我得到一个"内部错误"异常,所以我想知道问题是否在我的特定请求中,或者是否存在问题。
cUrl请求如下所示:
curl https://(canvas_api_url)?access_token=(access-token)
-X POST
-F'注册[user_id] = 241'
-F'注册[type] = StudentEnrollment'
我的请求如下:
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();
我的请求有问题吗?
答案 0 :(得分:0)
我看到这篇文章很老了,但是基于快速查看它的一些想法。你没有说出你想要完成的事情,所以这里有一些潜在的错误:
user_id
和type
。具体内容在此处的文档中列出:https://canvas.instructure.com/doc/api/enrollments.html