DataConnector
プロキシサーバー

A proxy server is an intermediary server that acts as a gateway between a client computer and another server, typically the Internet. When an API call is made to access a website or other online resource, the request is sent first to the proxy server, which then forwards the request to the target server on behalf of the client. Likewise, the responses come back to the proxy server before going to the user.

In order to use the proxy server for all providers, add the following properties to the connection string:

Connection string with Basic Proxy Authentication

The connection string can be configured with the Proxy Username and Password credentials, as in the following code example.

コードのコピー
const string OAuthTokenEndpoint = @" https://xxx.xxx.xxx.xxx.com /oauth_token.do";
const string Url = @" https://xxx.xxx.xxx.xxx.com";
const string ClientId = @"******";
const string ClientSecret = @"*****";
const string Username = @"****";
const string Password = @"****";
const string ProxyAuthScheme = @"Basic";
const string ProxyServer = @"***.***.***.***";
const int ProxyPort = ****;
const string ProxyUsername = "yourproxyUsername";
const string ProxyPassword = "yourproxyPassword";
string ConnectionString = @”Username={ Username };Password={ Password };OAuth Client Id={ ClientId }; 
       OAuth Client Secret={ ClientSecret }; OAuth Token Endpoint={ OAuthTokenEndpoint }; Url={Url} ;
       Proxy Server={ ProxyServer };Proxy Port={ ProxyPort };Proxy Auth Scheme={ ProxyPort };
       Proxy Username={ ProxyUsername };Proxy Password={ ProxyPassword}”;

Connection string with No Proxy Authentication

When no authentication is going to be used with proxy, the connection string can be configured with the Proxy Server and Proxy Port, as in the following code example.

コードのコピー
string ConnectionString = @”Username= yourusername ;Password= yourpassword;OAuth Client Id=***********; 
             OAuth Client Secret= *******; OAuth Token Endpoint= https://xxx.xxx.xxx.xxx.com /oauth_token.do; 
             Url= https://xxx.xxx.xxx.xxx.com; Proxy Server=  ***.***.***.***;Proxy Port= **** ”;       

Data retrieval

After setting up the connection string in any of the above ways, it can be used to connect and retrieve data like in the following code example.

コードのコピー
string sql = @"SELECT * From TableName";

using (var con = new C1ServiceNowConnection(ConnectionString))
{
    con.Open();
    var command = con.CreateCommand();
    command.CommandText = sql;
    var reader = command.ExecuteReader();
}