sharepoint 2013 Sp.Webproxy.invoke not include headers -
i working on sharepoint-hosted app needs call yammer rest api javascript. access token has been obtained. need pass in request headers. have use sharepoint cross-domain library in app.js. doesn't matter how tried, sp.webproxy calls endpoint without including header. turns out sharepoint intentionally ignores "authorizatio" header. know alternative approach? thank you.
function getyammer() { var request = new sp.webrequestinfo(); request.set_url("https://www.yammer.com/api/v1/messages/algo.json"); request.set_headers({ "authorization": "bearer abcedfghijk" }); //headers not sent out external service request.set_method("get"); var response = sp.webproxy.invoke(context, request); context.executequeryasync(onsuccess, onfail); function onsuccess() { if (response.get_statuscode() == 200) { removeposts('yammer'); var responsebody = json.parse(response.get_body()); (var = 0, len = responsebody.data.length; < len; i++) { vm.addyammermessage(responsebody.data[i]); } sortpost(); } else { var httpcode = response.get_statuscode(); var httptext = response.get_body(); window.console && console.log("error code returned:" + httptext); } }; function onfail() { window.console && console.log("get yammer messages failed:" + response.get_body()); };
};
Comments
Post a Comment