Sunday 15 April 2012

c# - How to perform a search using the Desk API v2 -



c# - How to perform a search using the Desk API v2 -

has 1 had success using desk's public api searches either customers or companies? using restsharp library submit requests, works fine creating new companies or pulling individual cases id. here sample of i'm trying do.

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 info = system.text.encoding.ascii.getstring(response.rawbytes);

i've tried switching out "q" in request body either "name" or "domain," response same:

{"message":"invalid search parameters"}

any advice appreciated.

maybe alter

resource = "companies/search"

to

resource = "companies/search?"

also sure uri encode query string

debugging tips:

use postman chrome extension, other browsers might have similar tools inspect network xhr requests sent desk search box in desk app.

c# oauth restsharp

No comments:

Post a Comment