I am getting some odd inconsistent results. This web method was working fine earlier. I had only added some UI stuff (jquery-ui and twitter-bootstrap). I tried removing all that UI stuff, but I still get this error. I'm not sure if there is something wrong with the JIRA server or if I'm not creating my requests correctly.
I've tried doing the following (based on this):
- use
System.Web.HttpUtility.HtmlDecode
textVar = textVar.Replace((char)(0x1F), ' ').Trim();
However, neither have worked.
This code doesn't throw an exception, but he var response
in the C# code has this error stack trace. Output:
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) -
The empty quote ''
is actually some other character that looks similar to: [US]
. Is there something I can do to fix this or does this seem to be a JIRA sever issue?
My minimized example:
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);
}
Also, I've tried entering both of these in my Firefox browser and they return the expected results:
https://www.url.com/jira/rest/api/2/search?jql=assignee%3Dmsalim
https://www.url.com/jira/rest/api/2/search?jql=assignee=msalim