I'm sorry if question was previously submitted but I'm not able to find a way to do convert this c# code (made as test).
I have no idea of how I can call a method of a class (I know how to do in c#)
I have no idea of how I can call a method of a class (I know how to do in c#)
B4X:
public string Test(string Procedure,string Method , Dictionary<string, string> parametri)
{
// URL is something like http://www.mysite.com/Service/WebApiClass
_client = WebRequest.Create(_url);
// HOW can I translate this in B4A?
_client.Method = Procedure;
_client.Headers.Clear();
_client.Headers.Add("ID_NOERROR", "-1");
_client.Headers.Add("ID_AUTOPROXY", "-1");
_client.Headers.Add("ID_TYPE", Procedure);
if (_token != "")
_client.Headers.Add("token", Crypt(_token));
if (_idCliente!="" )
_client.Headers.Add("idcliente", Crypt(_idCliente));
if (parametri != null)
{
foreach (KeyValuePair<string, string> pair in parametri)
{
_client.Headers.Add(pair.Key, pair.Value);
}
}
String encoded = Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(_username + ":" + _password));
_client.Headers.Add("Authorization", "Basic " + encoded);
string resp = "";
try
{
WebResponse webResponse = _client.GetResponse();
StreamReader streamReader = new StreamReader(webResponse.GetResponseStream(), true);
resp = streamReader.ReadToEnd();
streamReader.Close();
}
catch (Exception ex)
{
//Log Error
resp = null;
}
return resp;
}