c# - why does my web api client call not work in Raspberry Pi2 Iot -


i have code:

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; } } 

i call so:

update(" header", " string tc"); 

in c# desktop app works. in windows 10 iot on raspberry pi2 device not work. yet, when calling web api server *in iot) works fine. ?

i using code year , works:

    using windows.web.http;       using (httpclient httpclient = new httpclient())     {         httpclient.defaultrequestheaders.add("cache-control", "no-cache");         try         {             var o = new             {                 operation = "newevent",                 location_id = locationid,                 eventname = eventname             };              httpstringcontent content = new httpstringcontent(jsonconvert.serializeobject(o), windows.storage.streams.unicodeencoding.utf8, "application/json");              httpresponsemessage response = await httpclient.postasync(new uri(urlpostdata), content);             response.ensuresuccessstatuscode();             string responsebody = await response.content.readasstringasync();             // todo: responsebody         }         catch (exception)         {             // todo: deal exception - server not found, 401, 404, etc.         }     } 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -