Answer the question
In order to leave comments, you need to log in
Error in Rest Client when executing get request?
I want to make a GET request, but an error occurs:
statusCode: 302
headers: { date: 'Mon, 25 Feb 2019 06:09:49 GMT',
server: 'PHttp/2.6 Win32NT',
'access-control-allow-origin': '*',
'access-control-allow-headers': '*',
'x-frame-options': 'SAMEORIGIN',
location: '/auth/sign_in?ReturnUrl=%252home',
'x-aspnet-version': '4.0.30319',
'content-length': '147',
'cache-control': 'private',
'content-type': 'text/html',
connection: 'close' }
Result:
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/auth/sign_in?ReturnUrl=%252home">here</a></h2>
</body><html>
var http = require('http');
const querystring = require('querystring')
var data = querystring.stringify({
Login: "login",
Password: "password"
})
var optionsget = {
host: 'localhost',
port: 8080,
path: '/home',
method: 'GET',
auth: data,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data)
}
};
var reqGet = http.request(optionsget, function(res) {
console.log("Status: ", res.statusCode);
console.log("Headers: ", res.headers);
res.on('data', function(d) {
console.info('Result:\n');
process.stdout.write(d);
});
});
reqGet.end();
reqGet.on('error', function(e) {
console.error("ERROR" +e);
});
Answer the question
In order to leave comments, you need to log in
Judging by the status 302, the page has been moved to another url and now requires authorizationlocation: '/auth/sign_in?ReturnUrl=%252home',
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question