How to call JAVA API from ASP .Net Core
public static string GetAPIResponse()
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
string response = string.Empty;
string token = “VGhpcyB0b2tlbiBpcyBnZW5lcmF0ZWQgYnkgVmliZXJzb2w=“;
string URL = “https://Vibersol.com/API/GetUserDetails/”
string AccessKey = “Basic ” + token;
var content = “grant_type=Admin&username=Vibersol&password=123”;
using (WebClient wc = new WebClient())
{
wc.Headers[“Content-Type”] = “application/x-www-form-urlencoded”;
wc.Headers[“Authorization”] = AccessKey;
wc.Headers[“X-User-Agent”] = “Test”;
response = wc.UploadString(URL, “POST”, content);
}
return response;
}