1

When I perform a request

curl -I api-ip.fssprus.ru/api/v1.0/

I get the following response

HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Tue, 15 May 2018 09:56:49 GMT
Content-Type: text/html
Content-Length: 154
Location: https://api-ip.fssprus.ru

Why does this happen? What do I do wrong?

Holger Just
  • 52,918
  • 14
  • 115
  • 123
vasilek
  • 37
  • 1
  • 8
  • That's what the response to your request is. What are you trying to do? – Simon Brahan May 15 '18 at 10:08
  • https://stackoverflow.com/questions/18474690/is-there-a-way-to-follow-redirects-with-command-line-curl – Sneftel May 15 '18 at 10:16
  • I need to send GET request to https://api-ip.fssprus.ru. but there is a 302 error. tried to send just CURl, then the error goes out too – vasilek May 15 '18 at 10:59
  • curl http://api-ip.fssprus.ru/api/v1.0/ 302 Found

    302 Found


    nginx
    – vasilek May 15 '18 at 10:59
  • need to send "curl" -X GET -d "@/test/request.JSON" -D "//test/hdrout.HDR" -H "Content-Type: application/json" -H "Accept: application/json" -I http://api-ip.fssprus.ru/api/v1.0/ – vasilek May 15 '18 at 11:00

1 Answers1

3

the first thing you're doing wrong, is hitting the unencrypted http api on port 80, which is evidently not supported. fix that by hitting the encrypted httpS api on port 443 instead, by adding https:// to your url.

the second thing you're doing wrong, is not following http redirects, because that response is a HTTP 302 Redirect, which you don't follow. fix that by using the --location argument. (then curl will automatically follow http location redirects)

fixing those 2 things, and you end up with:

curl --location -I https://api-ip.fssprus.ru/api/v1.0/
hanshenrik
  • 19,904
  • 4
  • 43
  • 89
  • try to use location, but get this errorcurl: (35) error:0D0C50A1:asn1 encoding routines:ASN1_item_verify:unknown message digest algorithm – vasilek May 16 '18 at 08:40
  • @vasilek That's a separate issue. If adjusting the call as hanshenrik suggested resolved your question about a redirect response, make sure to mark his answer "accepted". Then, start a new question if you have more stuff to ask about. – Sneftel May 16 '18 at 08:50
  • I can't check suggest hanshenrik , because I have another error – vasilek May 16 '18 at 08:59
  • @vasilek that is indeed a separate issue. seems this api requires TLS 1.2, and your curl/ssl lib doesn't support it, by the looks of it. run `curl --version`, what do you get? TLS 1.2 requires curl version 7.34.0 or higher, and a supporting ssl/tls lib – hanshenrik May 16 '18 at 09:02