I'm doing some test from my WP8 device and try to connect a native app to the BaasBox service. Since BaasBox doesn't have support for WP yet, i'm trying to establish a connection following the supported JavaScript documentation
The C# code using the HttpClient
class:
using (var client = new HttpClient())
{
//Send HTTP request
//This code sets the base URI for HTTP requests,
//and sets the Accept header to "application/json", which tells the server to send data in JSON format
client.BaseAddress = new Uri("http://openerp.homelinux.com:9000");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//
BaasBoxLogin login = new BaasBoxLogin();
login.userName = "testuser";
login.password = "testpwd";
login.appcode = "1234567890";
HttpResponseMessage response = await client.PostAsJsonAsync(new Uri("http://openerp.homelinux.com:9000/console/"), login);
if (response.IsSuccessStatusCode)
{
//get the uri of the created resource
Uri gizmoResponse = response.Headers.Location;
}
else
{
this.LblToken.Text = "TokenId: NOT Found";
}
}
When running and debugging the above code from my device the following messages is generated after trying to establish the connection:
{
StatusCode: 404,
ReasonPhrase: 'Not Found',
Version: 0.0,
Content: System.Net.Http.StreamContent,
Headers: {
Content-Length: 399 Content-Type: application/json; charset=utf-8
}
}
As mentioned before, I'm using the HttpClient
class. However, i'm considering to use the HttpWebRequest
to achieve log in to the BaasBox service
Any idea how to perform this?
The answer provided by @eliantor is correct but the endpoint is wrong. The right one is
http://openerp.homelinux.com:9000/login
without the last/
.