Example #1
0
        internal static UiPathWebApi MakeApi(AuthToken authToken)
        {
            ServiceClientCredentials creds = null;

            if (authToken.Authenticated == false)
            {
                creds = new BasicAuthenticationCredentials();
            }
            else if (authToken.WindowsCredentials)
            {
                creds = new NetworkAuthenticationCredentials
                {
                    Credentials = CredentialCache.DefaultNetworkCredentials
                };
            }
            else
            {
                creds = new TokenCredentials(authToken.Token);
            }

            var api = new UiPathWebApi(creds)
            {
                BaseUri = new Uri(authToken.URL)
            };

            api.SetRetryPolicy(null);
            api.SerializationSettings.Converters.Add(new SpecificItemDtoConverter());
            return(api);
        }
        internal static UiPathWebApi MakeApi(AuthToken authToken)
        {
            ServiceClientCredentials creds = null;

            if (authToken.Authenticated == false)
            {
                creds = new BasicAuthenticationCredentials();
            }
            else if (authToken.WindowsCredentials)
            {
                creds = new NetworkAuthenticationCredentials
                {
                    Credentials = CredentialCache.DefaultNetworkCredentials
                };
            }
            else
            {
                creds = new TokenCredentials(authToken.Token);
            }

            var api = new UiPathWebApi(creds)
            {
                BaseUri = new Uri(authToken.URL)
            };

            api.SetRetryPolicy(null);
            api.SerializationSettings.Converters.Add(new SpecificItemDtoConverter());
            if (authToken.OrganizationUnitId.HasValue)
            {
                api.HttpClient.DefaultRequestHeaders.Add("X-UIPATH-OrganizationUnitId", authToken.OrganizationUnitId.Value.ToString());
            }
            return(api);
        }