1
有沒有人使用Desk的公共API成功搜索客戶或公司?我正在使用RestSharp庫提交請求,這對於創建新公司或通過ID提取個別案例工作良好。這是我想要做的一個樣本。如何使用Desk API v2執行搜索
RestClient client = new RestClient();
client.Authenticator = RestSharp.Authenticators.OAuth1Authenticator.ForProtectedResource(Configuration.ApiKey, Configuration.SiteKey, Configuration.Token, Configuration.TokenSecret);
client.BaseUrl = "https://imathlete.desk.com/api/v2";
string json = new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
{ "q", "my company" }
});
RestRequest request = new RestRequest {
Method = Method.GET
, Resource = "companies/search"
, RequestFormat = DataFormat.Json
};
request.AddBody(json);
RestResponse response = (RestResponse)client.Execute(request);
string data = System.Text.Encoding.ASCII.GetString(response.RawBytes);
我已經嘗試切換出請求主體的「Q」爲任一「名」或「域」,但響應總是相同的:
{"message":"Invalid search parameters"}
任何意見將是不勝感激。