• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

CURLOPT_HEADER returns 401

I need to get the location header. From what I've read, this should be as simple as

curl_setopt($c, CURLOPT_HEADER, true);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, false);

Open in new window


If I don't include those two options, the curl request works fine, but I'm not able to get the location header.

If I do include those two options, then I get a 401 error.

The Location that is being returned should be a URL that does require an additional login. What am I doing wrong?
0
quizwedge
Asked:
quizwedge
  • 4
  • 2
3 Solutions
 
gr8gonzoConsultantCommented:
The 401 code isn't an error. It's just the code that tells the browser to prompt for authentication. Are you looking for a URL that happens AFTER login?
0
 
Ray PaseurCommented:
By themselves, these two instructions don't tell us much.  What is the URL you're making the request to?  Why are you telling cURL not to follow the location headers?
0
 
quizwedgeAuthor Commented:
In generating the needed information for a response, I figured out my issue. I wasn't thinking about previous requests. Looking too much at the trees to see the forest.

I have to make a call to get a session token and then use that session token to make my PUT call. Since I wasn't parsing out the headers from the previous request, I wasn't successfully grabbing the session token. Everything is working now.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
quizwedgeAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for quizwedge's comment #a40346289

for the following reason:

The issue was a previous request. I didn't have enough information in the question to allow others to provide an answer and once I got that information, I was able to find the solution.
0
 
gr8gonzoConsultantCommented:
If our questions prompted you in a direction that led to the correct answer, I would consider awarding points to those comments.
0
 
quizwedgeAuthor Commented:
It wasn't any one question that prompted me, but I'll split points.
0
 
quizwedgeAuthor Commented:
The issue was a previous request. I didn't have enough information in the question to allow others to provide an answer and once I got that information, I was able to find the solution.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now