田爽 1 year ago
parent
commit
c9e9bcb8d4
1 changed files with 14 additions and 6 deletions
  1. 14 6
      src/Hotline.YbEnterprise.Sdk/EnterpriseService.cs

+ 14 - 6
src/Hotline.YbEnterprise.Sdk/EnterpriseService.cs

@@ -45,8 +45,12 @@ namespace Hotline.YbEnterprise.Sdk
             }
             var path = _config.AddressUrl + "platform/12345/selectEnterpriseList";
             var rest = new RestRequest(path, Method.Post);
-            rest.AddHeader("content-type", "application/json");
-            rest.AddHeader("Blade-Auth", token.TokenType + " " + token.AccessToken);
+            //rest.AddHeader("content-type", "application/json");
+            //rest.AddHeader("Blade-Auth", token.TokenType + " " + token.AccessToken);
+            rest.AddHeaders(new[] {
+             new KeyValuePair<string, string>("content-type", "application/json"),
+             new KeyValuePair<string, string>("Blade-Auth", token.TokenType + " " + token.AccessToken)
+            });
             var res = await ExecuteAsync<EnterpriseListRequest, EnterpriseListResponse>(path, Method.Post, request, rest, cancellationToken);
             return res == null ? null : res.data;
         }
@@ -66,10 +70,14 @@ namespace Hotline.YbEnterprise.Sdk
 
             var path = _config.AddressUrl + "blade-auth/oauth/getAccessToken";
             var rest = new RestRequest(path, Method.Post);
-            rest.AddHeader("content-type", "application/json");
-            rest.AddHeader("Authorization", "Basic " + authorization);
-            rest.AddHeader("Tenant-Id", _config.TenantId);
-            var res = await ExecuteAsync<string, EnterpriseServiceResponse>(path, Method.Post, "", rest, cancellationToken);
+            //rest.AddHeader("content-type", "application/json");
+            //rest.AddHeader("Authorization", "Basic " + authorization);
+            //rest.AddHeader("Tenant-Id", _config.TenantId);
+            rest.AddHeaders(new[] { 
+                new KeyValuePair<string, string>("content-type", "application/json"),
+	            new KeyValuePair<string, string>("Authorization", "Basic " + authorization),
+	            new KeyValuePair<string, string>("Tenant-Id", _config.TenantId)});
+			var res = await ExecuteAsync<string, EnterpriseServiceResponse>(path, Method.Post, "", rest, cancellationToken);
 
             if (res is null)
                 throw new UserFriendlyException("获取token请求失败 authorization:" + authorization + " ,path:" + path + " , res:" + res.ToString());