[]
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:
Proxy Server - is the hostname or IP address of a proxy to route HTTP traffic through.
Proxy Port - is the TCP port the Proxy Server proxy is running on. The default value is set as 8080.
Proxy Auth Scheme - is the authentication type that the proxy server uses to authenticate to the HTTP proxy specified by Proxy Server and Proxy Port. The authentication type can be one of the following:
If this property is not set, no authentication will be used.
Proxy Username and Proxy Password - are the credentials to authenticate to the proxy server. These properties will only be available if Proxy Auth Scheme is set.
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}”;
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= **** ”;
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();
}