十六进制值 0x1F,是无效字符。第 1 行,位置 1
hexadecimal value 0x1F, is an invalid character. Line 1, position 1
我得到了一些奇怪的不一致结果。此网络方法之前运行良好。我只添加了一些 UI 东西(jquery-ui 和 twitter-bootstrap)。我尝试删除所有 UI 东西,但我仍然收到此错误。我不确定 JIRA 服务器是否有问题,或者我是否没有正确创建我的请求。
我已尝试执行以下操作 (based on this):
- 使用
System.Web.HttpUtility.HtmlDecode
textVar = textVar.Replace((char)(0x1F), ' ').Trim();
但是,两者都没有用。
这段代码没有抛出异常,但是他var response
在C#代码中有这个错误堆栈跟踪。输出:
RestSharp response status: Error -
HTTP response: Forbidden -
Forbidden -
'', hexadecimal value 0x1F, is an invalid character. Line 1, position 1. -
System.Xml.XmlException: '', hexadecimal value 0x1F, is an invalid character. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Char[] data, Int32 length, Int32 invCharPos)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
at System.Xml.Linq.XDocument.Parse(String text)
at RestSharp.Deserializers.XmlDeserializer.Deserialize[T](IRestResponse response)
at RestSharp.RestClient.Deserialize[T](IRestRequest request, IRestResponse raw) -
空引号 ''
实际上是其他一些看起来类似于 [US]
的字符。我可以做些什么来解决这个问题,或者这似乎是 JIRA 服务器的问题?
我的最小化示例:
private static string serverUrl = "https://www.url.com/jira";
private static string baseUrl = "/rest/api/2/";
private static string searchCommand = "search";
public static void QuickTest()
{
string username = HttpContext.Current.Session["jira_username"].ToString();
string pw = HttpContext.Current.Session["jira_password"].ToString();
//also tried hardcoding these values. didn't work either
//username = "";
//pw = "";
//create client
RestClient client = new RestClient(serverUrl)
{
Authenticator = new HttpBasicAuthenticator(username, pw)
};
//create query
string jql = "assignee=msalim";
//string jql = "assignee%3Dmsalim"; //didn't work either
//create request
var request = new RestRequest();
request.Resource = Path.Combine(baseUrl, searchCommand);
request.AddParameter(new RestSharp.Parameter()
{
Name = "jql",
Value = jql,
Type = ParameterType.GetOrPost
});
request.Method = Method.GET;
//get response
var response = client.Execute<Issues>(request);
string errorMessage = string.Format("RestSharp response status: {0} -\n HTTP response: {1} -\n {2} -\n {3} -\n {4} -\n ", response.ResponseStatus, response.StatusCode, response.StatusDescription, response.ErrorMessage, response.ErrorException);
System.Diagnostics.Debug.WriteLine(errorMessage);
}
另外,我已经尝试在我的 Firefox 浏览器中输入这两个,它们 return 预期的结果:
https://www.url.com/jira/rest/api/2/search?jql=assignee%3Dmsalim
https://www.url.com/jira/rest/api/2/search?jql=assignee=msalim
这个 solution 让我遇到了问题。我尝试了同事的 JIRA 登录名和密码,效果很好。 serverUrl
下的服务器已经禁止我再次登录,因为我发出了太多的请求。现在我必须与服务器管理员沟通才能解决这个问题。另一件需要注意的事情是,根据 JIRA,我提出的每个请求都算作 "failed login"。
我得到了一些奇怪的不一致结果。此网络方法之前运行良好。我只添加了一些 UI 东西(jquery-ui 和 twitter-bootstrap)。我尝试删除所有 UI 东西,但我仍然收到此错误。我不确定 JIRA 服务器是否有问题,或者我是否没有正确创建我的请求。
我已尝试执行以下操作 (based on this):
- 使用
System.Web.HttpUtility.HtmlDecode
textVar = textVar.Replace((char)(0x1F), ' ').Trim();
但是,两者都没有用。
这段代码没有抛出异常,但是他var response
在C#代码中有这个错误堆栈跟踪。输出:
RestSharp response status: Error -
HTTP response: Forbidden -
Forbidden -
'', hexadecimal value 0x1F, is an invalid character. Line 1, position 1. -
System.Xml.XmlException: '', hexadecimal value 0x1F, is an invalid character. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Char[] data, Int32 length, Int32 invCharPos)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
at System.Xml.Linq.XDocument.Parse(String text)
at RestSharp.Deserializers.XmlDeserializer.Deserialize[T](IRestResponse response)
at RestSharp.RestClient.Deserialize[T](IRestRequest request, IRestResponse raw) -
空引号 ''
实际上是其他一些看起来类似于 [US]
的字符。我可以做些什么来解决这个问题,或者这似乎是 JIRA 服务器的问题?
我的最小化示例:
private static string serverUrl = "https://www.url.com/jira";
private static string baseUrl = "/rest/api/2/";
private static string searchCommand = "search";
public static void QuickTest()
{
string username = HttpContext.Current.Session["jira_username"].ToString();
string pw = HttpContext.Current.Session["jira_password"].ToString();
//also tried hardcoding these values. didn't work either
//username = "";
//pw = "";
//create client
RestClient client = new RestClient(serverUrl)
{
Authenticator = new HttpBasicAuthenticator(username, pw)
};
//create query
string jql = "assignee=msalim";
//string jql = "assignee%3Dmsalim"; //didn't work either
//create request
var request = new RestRequest();
request.Resource = Path.Combine(baseUrl, searchCommand);
request.AddParameter(new RestSharp.Parameter()
{
Name = "jql",
Value = jql,
Type = ParameterType.GetOrPost
});
request.Method = Method.GET;
//get response
var response = client.Execute<Issues>(request);
string errorMessage = string.Format("RestSharp response status: {0} -\n HTTP response: {1} -\n {2} -\n {3} -\n {4} -\n ", response.ResponseStatus, response.StatusCode, response.StatusDescription, response.ErrorMessage, response.ErrorException);
System.Diagnostics.Debug.WriteLine(errorMessage);
}
另外,我已经尝试在我的 Firefox 浏览器中输入这两个,它们 return 预期的结果:
https://www.url.com/jira/rest/api/2/search?jql=assignee%3Dmsalim
https://www.url.com/jira/rest/api/2/search?jql=assignee=msalim
这个 solution 让我遇到了问题。我尝试了同事的 JIRA 登录名和密码,效果很好。 serverUrl
下的服务器已经禁止我再次登录,因为我发出了太多的请求。现在我必须与服务器管理员沟通才能解决这个问题。另一件需要注意的事情是,根据 JIRA,我提出的每个请求都算作 "failed login"。