Hallo.
I have an issue about my POST HTTP request.
After i have given my Bearer token, ill get this issue:
“message”: “\n\n301 Moved Permanently\n\n
Moved Permanently \n
The document has moved <a href="http:****">here.
\n \nApache/ (Ubuntu) Server at ****** Port **\n\n”,
It looks like im getting redirected and therefor getting this message.
When im doing the exact same thing through POSTMAN, it works fine.
In POSTMAN this setting is turned on. When i turn it OFF ill get the same issue as in UiPath.
Can someone please help?
Anil_G
(Anil Gorthi)
March 8, 2023, 1:59pm
2
@christian.bendtsen
Automatic redirects is not yet a available feature in http request activity. As if now it is a limitation
You can try using custom code for the http request and use AllowAutoredirectProperty
Cheers
ppr
(Peter Preuss)
March 8, 2023, 2:00pm
3
Some statements from above maybe needs to be crosschecked (as HTTP Request did in the lab the following automatically). But for checking redirections also have a look here:
can you check if the strategy of detecting redirects will match your case?
[grafik]
EDIT:
Using target framework: Windows, VB.Net
[grafik]
[grafik]
myResponse = myHttpClient.GetAsync(myUrl)
From the result we can check the status code, comparing the location info:
[grafik]
Hey
I’ll tried to invoke the code, and used AllowAutoredirected, but nothing changes…
the websites are the same, only changes is the ‘s’ in the http, i’ll try to change that as well, still got the same problem …
ppr
(Peter Preuss)
March 8, 2023, 2:29pm
6
this part is unclear on what was done in detail, what was returned
Returned: “http://"
insted of:"https:// ”
I have already disabled “Enable SSL certificate verification”
Do you have any other good suggestions?
Anil_G
(Anil Gorthi)
March 9, 2023, 1:09pm
9
christian.bendtsen:
nothing
@christian.bendtsen
When you say you tried invoke code…Can you show the code you tried…
cheers
try
{
var webRequest = System.Net.HttpWebRequest.Create(strEndPoint) as System.Net.HttpWebRequest;
if (webRequest != null)
{
webRequest.Method = "POST";
webRequest.Timeout = 60000;
webRequest.ContentType = "application/json;v=1";
webRequest.Accept="application/json;v=1";
webRequest.Headers.Add("Accept-Encoding","gzip, deflate, br");
webRequest.AllowAutoRedirect=true;
webRequest.Headers.Add("Authorization", StrToken);
using (var streamWriter = new StreamWriter(webRequest.GetRequestStream())) {
}
using (System.IO.Stream s = webRequest.GetResponse().GetResponseStream())
{
using (System.IO.StreamReader sr = new System.IO.StreamReader(s))
{
StrResponse = sr.ReadToEnd();
}
}
IntStatusCode = 200;
}
}
catch (System.Net.WebException ex)
{
if (ex.Status == System.Net.WebExceptionStatus.ProtocolError)
{
var response = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
Console.WriteLine("Errorcode: {0}", response);
StrResponse = response.ToString();
IntStatusCode = (int) ((System.Net.HttpWebResponse) ex.Response).StatusCode;
}
else
{
Console.WriteLine("Error: {0}", ex.Status);
}
}Preformatted text
here you go, its written in C#
Anil_G
(Anil Gorthi)
March 9, 2023, 1:29pm
11
@christian.bendtsen
Try including a cookie container as well
CookieContainer cookieContainer = new CookieContainer();
WebRequest.CookieContainer = cookieContainer;
And I hope in Postman when autoredirect is set to true that is when you have the correct request output
cheers
ppr
(Peter Preuss)
March 9, 2023, 1:40pm
12
@christian.bendtsen
Kindly note why we mentioned HttpClient (attached link from above to the redirect detection code lines) for new Custom Implementations:
Taken from:
2 Likes