I have one particular request in my app that requires Basic authentication, so I need to set the Authorization header for that request. I read about setting HTTP request headers, but from what I can tell, it will set that header for all requests of that method. I have something like this in my code:
$http.defaults.headers.post.Authorization = "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==";
But I don’t want every one of my post requests sending this header. Is there any way to send the header just for the one request I want? Or do I have to remove it after my request?
There’s a headers parameter in the config object you pass to
$httpfor per-call headers:Or with the shortcut method:
The list of the valid parameters is available in the $http service documentation.