Avatar

HttpWebRequest

0

Is it possible to use HTTPWebRequest Post to get  Authenticate in geotab? I tried different url not quite sure how I pass the parameters. Below was the lastest string I tried:

https://myxxx.geotab.com/apiv1/Authenticate?Username=xxx,database=xxx,password=xxx

I am trying to avoid using Geotab.Checkmate.ObjectModel since when I build a project using it results in 110 files on my release folder.

Any help is appreciated.

Selvam Durairaj

Iniciar sesión para dejar un comentario.

5 comentarios

0
Avatar

Getting the same error 

"The remote server returned an error: (411) Length Required."

Below is the entire code

string s1 = "xxx";
string s2 = "xxx";
string s3 = "xxx";

string MoodysWebstring = "https://xxx.geotab.com/apiv1/Authenticate?password=" + s2 + "&userName=" + s1 + "&database=" + s3;

Uri MoodysWebAddress = new Uri(MoodysWebstring);

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(MoodysWebAddress);
request.Method = "POST";
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();
}

Selvam Durairaj 0 votos
0
Avatar

Hello Selvam, 

You are attempting to make a POST request in your code above. But the format for your call is of a GET Request.

Please refer to this link for an example of making an Authenticate call using a POST request.

Shivansh Singla 0 votos
0
Avatar

On the link it does show POST.

Anyway I changed it to GET and it worked.

Thanks for your help

Selvam Durairaj 0 votos