16-11-20 02:46 PM
Thanks.
var _data = new Data();
var userName = _username;
var password = _password;
var credentials = new NetworkCredential(userName, password);
using (var httpClient = new HttpClient(new HttpClientHandler { Credentials = credentials }))
{
httpClient.DefaultRequestHeaders.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata=verbose"));
var response = await httpClient.GetAsync(endpointUrl2);
if (response.IsSuccessStatusCode)
{
string apiResponse = await response.Content.ReadAsStringAsync();
_data = JsonConvert.DeserializeObject<Data>(apiResponse);
}
}
20-11-20 02:34 PM
04-12-20 10:15 PM
07-12-20 04:31 PM
09-12-20 08:52 AM
23-12-20 07:20 AM
Hi, i cant use this, compile error for NetworkCredential? I have reference to System.Net in code option?
string GetsalesagentbySalesID(string salesId,string userName,string password,string url,string salesId)
{
try
{
// Initialization.
responseObj = string.Empty;
//...
//Inparameters
//userName
//password
//url
//salesId
var credentials = new NetworkCredential(userName, password);
// Posting.
using (var httpClient = new HttpClient(new HttpClientHandler { Credentials = credentials }))
{
// Setting content type.
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//...
// Initialization.
// HTTP POST
var response = httpClient.GetAsync(url + salesId);
// Verification
if (response.IsSuccessStatusCode)
{
responseObj = response.Result.Content.ReadAsStringAsync().Result;
}
}
return responseObj;
}
catch
{
return "Error";
}
}
23-12-20 08:51 AM
Hi Goran,
have you included an "External Reference" to "System.Net.Http.dll"?
23-12-20 03:56 PM
Yes but i find that the .Net Framework is 4.0 and it must be 4.5 to use HttpClient
------------------------------
Goran Rosander
------------------------------
25-01-22 05:03 PM
Hi @Tomasz Sukiennik, would you mind sharing the code that you use for NTLM authentication in BP? I have been trying to get several codes to work (including the one posted above by Samuel Ezeala), but I'm getting an error message indicating that asynchronous calls are not working in BP.
Any guidance that you can provide would be much appreciated! Thanks a lot!
11-10-22 03:40 PM