jeudi 21 avril 2016

HI I am developing an application in which i need to call a Web API from web service ? Anyone have idea over it how to call API in web service

here is some code which i tried but it doesnt work //my method from web service [WebMethod] public string TempTestAPI(string str1,string str2) { string strreturn = string.Empty;

    using (var client = new  HttpClient())
    using (var content = new MultipartFormDataContent())
    {

        client.BaseAddress = new Uri(http://localhost:4040);
        //call to API
        var result = client.PostAsync("api/GetString", content).Result;

        var strdictid = result.Content.ReadAsStringAsync().Result;

    }

    return strreturn;
}




Aucun commentaire:

Enregistrer un commentaire