How to call a rest webservice from a custom component by passing header parameters
Summary
How to call a rest webservice from a custom component by passing header parametersContent
Hi,
I tried following the below blog to call a webservice:-
But i need to pass header parameters to call the rest service.
Header params:- { 'kmauthtoken' : '{\"localeId\":\"en_US\",\"localeOverride\":\"true\"}' }
I tried to modify the code mentioned in the blog as mentioned in the code snippet but it didn't work:-
Could you please let me know how to pass header parameters in the below code..
Thanks,
Sweta
Code Snippet
self.endpointAddress = self.properties.serviceId + '/' + self.properties.endpointId; var ep = RestHelper.get(self.endpointAddress); var headerParam = new Headers(); headerParam.append('kmauthtoken', '{\"localeId\":\"en_US\",\"localeOverride\":\"true\"}'); var request = new Request(ep, {headers: headerParam}}; ep.fetch(request).then(function(result) { --> result.response gives status 404 here if (result.response.ok) { //update the observable that is bound in the UI self.messageText = ko.observable(result.body.data); } else {
0