有没有人使用Desk的公共API成功搜索客户或公司?我正在使用RestSharp库提交请求,这对于创建新公司或通过ID提取个别案例非常有效。以下是我尝试做的一个示例。
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);
我试过切换&#34; q&#34;在请求正文中&#34; name&#34;或&#34;域名,&#34;但反应总是一样的:
{"message":"Invalid search parameters"}
非常感谢任何建议。
答案 0 :(得分:0)
也许改变
Resource = "companies/search"
到
Resource = "companies/search?"
还要确保对您的查询字符串进行URI编码
调试提示: