mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Adding support for sending request headers in azure core rest request API (#16443)
* Adding support for sending additional headers in azure http requests * Added session ids in all azure rest calls * Fixed param name * Adding default parameter value for request headers
This commit is contained in:
@@ -333,8 +333,9 @@ export async function getSelectedSubscriptions(appContext: AppContext, account?:
|
||||
* @param requestBody Optional request body to be used in PUT and POST requests.
|
||||
* @param ignoreErrors When this flag is set the method will not throw any runtime or service errors and will return the errors in errors array.
|
||||
* @param host Use this to override the host. The default host is https://management.azure.com
|
||||
* @param requestHeaders Provide additional request headers
|
||||
*/
|
||||
export async function makeHttpRequest(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, path: string, requestType: HttpRequestMethod, requestBody?: any, ignoreErrors: boolean = false, host: string = 'https://management.azure.com'): Promise<AzureRestResponse> {
|
||||
export async function makeHttpRequest(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, path: string, requestType: HttpRequestMethod, requestBody?: any, ignoreErrors: boolean = false, host: string = 'https://management.azure.com', requestHeaders: { [key: string]: string } = {}): Promise<AzureRestResponse> {
|
||||
const result: AzureRestResponse = { response: {}, errors: [] };
|
||||
|
||||
if (!account?.properties?.tenants || !Array.isArray(account.properties.tenants)) {
|
||||
@@ -375,11 +376,14 @@ export async function makeHttpRequest(account: azdata.Account, subscription: azu
|
||||
return result;
|
||||
}
|
||||
|
||||
const reqHeaders = {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${securityToken.token}`,
|
||||
...requestHeaders
|
||||
};
|
||||
|
||||
const config: AxiosRequestConfig = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${securityToken.token}`
|
||||
},
|
||||
headers: reqHeaders,
|
||||
validateStatus: () => true // Never throw
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user