c# - yammer get user token yammer REST API -
i'm trying add user yammer group, need have token of user whom want add group. i've used following endpoint access user token
https://api.yammer.com/api/v1/oauth/tokens.json?user_id={0}&consumer_key={1}
for consumer_key i'm passing clientid of yammer application i've created (using verified admin account).
the problem user endpoint working fine , returning me json response. user endpoint returning "the remote server returned error: (400) bad request."
please, find code below
private yammerjsonusercontract getuserdetailsfromyammer(string userid, string clientid) { yammerjsonusercontract objuser = null; try { string url = string.format(this.userimpersonationurl, userid, clientid); string jsonstring = postyammerjson(url, this._adminaccesstoken, "get"); yammerjsonusercontract [] objusercollection = newtonsoft.json.jsonconvert.deserializeobject<yammerjsonusercontract[]>(jsonstring); objuser = objusercollection[0]; } catch (exception ex) { throw ex; } return objuser; } private string postyammerjson(string url, string accesstoken, string httpmethod) { string json = string.empty; try { httpwebrequest yammerrequest = httpwebrequest.create(url) httpwebrequest; yammerrequest.method = httpmethod; yammerrequest.contenttype = "application/json; odata=verbose"; yammerrequest.accept = "application/json; odata=verbose"; yammerrequest.contentlength = 0; yammerrequest.headers.add("authorization", string.concat("bearer ", accesstoken)); using (httpwebresponse response = yammerrequest.getresponse() httpwebresponse) { encoding encode = encoding.getencoding("utf-8"); streamreader reader = new streamreader(response.getresponsestream(), encode); json = reader.readtoend(); } } catch (exception ex) { throw ex; } return json; }
can please let me know i'm missing , why api returning user details users not all.
waiting response.
cheers amlan
this long shot maybe need add authorization header request value "oauth".
something like:
request.headers.authorization = oauth;
Comments
Post a Comment