You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

How to call a rest webservice from a custom component by passing header parameters

edited Apr 15, 2019 9:36AM in Visual Builder 3 comments

Summary

How to call a rest webservice from a custom component by passing header parameters

Content

Hi,

I tried following the below blog to call a webservice:-

https://blogs.oracle.com/groundside/web-component-techniques-integrating-components-with-vbcs-service-endpoints

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 {
   

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!