All:
There is an Bible ASP.NET Web Application that I am implementing. Within the Bible ASP.NET Web Application, I invoke the following Third-party web service API url:
https://bibles.org/v2/passages.js?q[]=john+3:1-5&version=eng-KJVA
Within in the ASP.NET Web Application, I have the following code:
String populatedPassagesEndpointUri = "https://bibles.org/v2/passages.js?q[]=john+3:1-5&version=eng-KJVA";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(populatedPassagesEndpointUri);
request.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(ConfigurationManager.AppSettings.Get("APIToken") + ":" + "X"));
request.Method = "GET";
String test = String.Empty;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
test = reader.ReadToEnd();
reader.Close();
dataStream.Close();
}
If you analyze the Web Service API url that I use above, you will notice that it uses [] square brackets which I believe is a bad practice to use within URLs:
https://bibles.org/v2/passages.js?q[]=john+3:1-5&version=eng-KJVA
Sadly, it's the third-party who provides the Web Services API, so I can't do anything about it. I'm forced to use the URL with []
In any case, I executed the code above in my Bible ASP.NET Web application. However, the above Webservice api URL invocation gives me a 401 error. Does that have something to do with the [] square brackets in the URL? If yes, is there a way of escaping the [] square brackets in the URL before invoking the Web SErvice API URL call?