Using Network Credentials in BP Web API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
16-11-20 02:46 PM
I am having difficulty calling an API on Blue Prism. the API uses network Credentials. In C#, the code below does the job for me, But am unable to archive same using the Web API Services on Blue Prism.
Please is they any work around it, or do i have to write a custom object for this purpose?
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);
}
}
------------------------------
Samuel Ezeala
Software Engineer | RPA Developer
eProcess, Ecobank Group
Lagos, Nigeria
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
20-11-20 02:34 PM
The WebAPI services feature supports HTTP Basic, token, OAuth2 Client, and OAuth2 JWT. If your network/web service is just using HTTP Basic, you should be good. There is an option to pre-send the authentication request as opposed to the traditional challenge/response format, so that may be something to consider.
Cheers,
------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-12-20 10:15 PM
------------------------------
Tomasz Sukiennik
RPA Developer
Digital Teammates
Europe/Lodz
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-12-20 04:31 PM
If you have to use NTLM for the authentication against the web service then I think you're stuck with doing it via the code stage you have.
Cheers,
------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-12-20 08:52 AM
Kind regards
------------------------------
Tomasz Sukiennik
RPA Developer
Digital Teammates
Europe/Lodz
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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";
}
}
------------------------------
Goran Rosander
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
23-12-20 08:51 AM
Hi Goran,
have you included an "External Reference" to "System.Net.Http.dll"?
------------------------------
Tobias Arnold
RPA Developer
ITERGO GmbH
Europe/Duesseldorf
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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!
------------------------------
Martina Kralova
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-10-22 03:40 PM
Can you share the code that you use for NTLM authentication in BP? I am facing the same issue.
@Eric Wilson: Since this thread is a bit long, is this been implemented somehow in Web APIs now, or do you have any code for the same in BP?
Thanks a lot in advance :)
------------------------------
Manish Rawat
Project Manager
Mercer
New Delhi
------------------------------
