0

I am trying to use this Quandl API for C++, https://github.com/zafuer/QuandlAPI_C, however every time I try to get data to download the excel sheet just fills with:

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>

The only change I have made to the quandl(linux).h code is to make the api version v3 in the link as opposed to v1.

Has anyone else had this issue? I cannot seem to figure out exactly why this happens or how to get around it.

Kyle
  • 89
  • 2
  • 13

1 Answers1

2

This error is not an error at all. It is an HTTP redirect, indicating that the page you are requesting has been relocated. The Location response header tells you where the page has moved to. Repeat the same request to that page.

A common cause of this these days is a request using http redirecting to https.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
  • How can I see the response headers? If I copy and paste the link I am using for this GET request in the C++ program into my browser the download works though which is confusing me. The information also gets retrieved if I use the link with wget and curl. – Kyle Nov 11 '17 at 20:09
  • @Kyle The browser etc process the 301 code and automatically redirect to the new page. Somewhere in the API you're using (I haven't looked) should be a way to see the headers, either as part of the original request data, or thru a supplementary call. – 1201ProgramAlarm Nov 11 '17 at 20:18
  • Ok so when I find the headers, should I be changing HTTP to HTTPS, I found a section in the API where the request is formed and it is using " HTTP/1.1\r\nHost: " in the request. Should I change this HTTP to HTTPS? – Kyle Nov 11 '17 at 20:25
  • When I use wget -S with the url I don't see a 301 Error either I just get a response back of 200 – Kyle Nov 11 '17 at 23:04
  • @Kyle because like a browser, wget processes the redirect and automatically requests the new URL. You only see the final non-redirecting response – Remy Lebeau Nov 12 '17 at 06:12
  • "*A common cause of this these days is a request using http redirecting to https.*" Another common cause is failing to send cookies that the server is expecting, it might redirect back to itself and include the missing cookies in the redirect response so they get sent back in the subsequent request. – Remy Lebeau Nov 12 '17 at 06:13
  • I'm using Qt on Windows. Dropping some openSSL .dll's in my program's folder and making it an https request worked for me. – CodeLurker Jul 06 '18 at 18:05