0

snapshot on server side

The above screenshot is while I debug the web service which is hit during my javascript call. I want to set the authorization header of the http request which is returning null. Can you please suggest me for this

2 Answers 2

2
 var config = {
      method: 'POST',
      url: 'https://somesite.com/',
      headers: {
            // key value pair of headers
            'Authorization': 'Your auth key'
      },
      data: body of request
  };
 $http(config)
         .success(function(){})
         .error(function(){})
Sign up to request clarification or add additional context in comments.

1 Comment

m getting error when seeing in the console Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at 82.223.29.24/SIUKService/Api/Login/loginUser. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
0

You can add this in your http request:

headers: {'Authorization': 'Basic key'}

Examples

GET request:

$http.get('url', { //same for post also
    headers: {'Authorization': 'Basic key'}
});

Post Request:

$http.post("url", requestData, {
    headers: { 'Authorization': 'Basic yourkey'}
}).success(function(responseData) {
    //do stuff with response
});

1 Comment

@user3012606 added post request example

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.