-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I add a value to an http header? #27
Comments
For anything beyond what the shorthand provides, you'll have to drop down a level of abstraction to create and manage let URL: NSURL(string: "http://api.imgur.com/3/gallery.json")
var mutableURLRequest = NSMutableURLRequest(URL: URL)
mutableURLRequest.setValue("...", forHTTPHeaderField: "Authorization")
let manager = Alamofire.Manager.sharedInstance // or create a new one
let request = manager.request(mutableURLRequest)
request.responseString { (request, response, string, error) in
// ...
} |
Alternatively, you could also set the Real documentation for this usage is forthcoming. |
Same comment as in #7 applies here as well. Would be great if new features weren't just closed but marked as new features. Thank you. |
@mattt Hi! Is your example valid for POST requests as well? I tried it but it returns 405 - method not allowed error. I tried explicitly specifying the http method in the url request like this,
Then I got a 500 - internal server error. EDIT: Yes, I'm sending it as a GET request. That's the cause of the 405 error. I tested it using hurl.it. Please show how to add a http header of a POST request as well? Also how do I add normal parameters to this POST request? Attempt: Okay, I got it working. The reason I got the 500 error was because I had forgotten to append the parameter. I accomplished it by adding these few extra lines.
Now it works fine. I hope you're working on something to simplify this process. :) |
I would like to re-open this issue. Sending additional request headers is mandatory on any REST API. |
+1 @endel |
|
+1 @endel |
👍 too |
+1 @endel |
1 similar comment
+1 @endel |
+1 |
+1, so important feature, but... |
+1 @endel |
+1 |
2 similar comments
+1 |
+1 |
For custom headers and
|
I am interested in adding an additional value to the following GET request's header:
The header in question is:
Authorization: Client-ID YOUR_CLIENT_ID
where the client_id would be my imgur client_id.Thanks for the awesome library!
The text was updated successfully, but these errors were encountered: