我正在使用Salesforce并希望在其中获取案例字段。找到了命令
curl https://yoursite.desk.com/api/v2/cases \
-u email:password \
-H 'Accept: application/json'
我在命令提示符下尝试了
curl https://xxx.desk.com/api/v2/cases \-u abc@gmail.com:xxxxxxxxx \ -H 'Accept: application/json'
我在C#中尝试了以下代码
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("https://xxxx.desk.com/api/v2/cases");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Accept = "text/xml";
httpWebRequest.Method = "GET";
httpWebRequest.Credentials = new NetworkCredential("username", "password");
var response = httpWebRequest.GetResponse();
但是它返回了一个错误
The remote server returned an error: (401) Unauthorized.
答案 0 :(得分:1)
CURL只是WebRequests的客户端
默认的C#选项是 WebRequest Class 您也可以使用Restsharp
答案 1 :(得分:1)
swap_pointers(a, b);