我正在尝试从.Net调用Service Now的webservice,我可以成功地插入记录,但是我无法使任何GET
请求工作。以下是我的可行的INSERT
代码:
public void insertTable(string tableName, string schema, string columnInfo, string shortDesrcipt, string longDescript)
{
using (ServiceNow_u_database_table tableReference = new ServiceNow_u_database_table())
{
insertResponse response = new insertResponse();
System.Net.ICredentials cred = new System.Net.NetworkCredential(Properties.Settings.Default.UserName, Properties.Settings.Default.Password);
tableReference.Credentials = cred;
insert tableInsert = this.getTableData(tableName, schema, columnInfo, shortDesrcipt, longDescript);
try
{
response = tableReference.insert(tableInsert);
}
catch (Exception error)
{
Console.WriteLine(error.Message);
}
}
}
那个可以正常工作。以下是不能用于 GET
的代码:
using (ServiceNow_u_database_table tableReference = new ServiceNow_u_database_table())
{
ServiceNowExport.com.servicenow.libertydev.u_database_table.getRecords recordGet = new getRecords();
System.Net.ICredentials cred = new System.Net.NetworkCredential(Properties.Settings.Default.UserName, Properties.Settings.Default.Password);
tableReference.Credentials = cred;
recordGet.name = this._tablePrefix + tableName;
getRecordsResponseGetRecordsResult[] response = tableReference.getRecords(recordGet);
if (response != null && response.Count() > 0)
{
return true;
}
}
当我运行该代码时,
response
始终为null
。 我正在遵循此页面上的指示。我知道它正在连接,因为如果我删除凭据行,我会得到未经授权的错误。有任何想法吗?谢谢!
true
而不是response
,这可能是原因吗? - Hari Pachuveetil