I'm running Windows 10 IoT Core on my Raspberry Pi 2 , and I need to make a call to my Web API using a C# client. Here's my code for it:
private const string route = "/api/Print";
public bool Update(string header, string tc)
{
bool success = false;
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("my uri");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var print = new Print { CompanyRef = new Guid(), Header = header, TC = tc };
var response = client.PutAsJsonAsync(route, print);
}
success = true;
return success;
}
public sealed class Print
{
public string Header { get; set; }
public string TC { get; set; }
public System.Guid CompanyRef { get; set; }
}
And here's how I make the call to it:
Update(" header", " string tc");
While it works great in my C# Desktop App, it just won't work on the Pi. Although, it works fine when I call a Get from the Web API server. Please Help!