Hibernia Hibernia - 1 year ago 101
Swift Question

Alamofire request with Header?

I'm trying to make a call to an API that now requires a Client ID as a header.

I don't know if I'm anywhere close here but this is what I attempted:

let clientID = "theclientIDIGotFromtheWebsite"

let urlString = "https://api.twitch.tv/kraken/channels/"

let headers: HTTPHeaders = [
"ClientID": clientID

Alamofire.request(urlString, headers: headers).responseJSON { response in

I get back an error : message = "No client id specified";

The same as if you click the link: https://api.twitch.tv/kraken/channels/

The mini-guide I followed to get the clientID is this: https://blog.twitch.tv/client-id-required-for-kraken-api-calls-afbb8e95f843#.27gij8pj9

The clientID I've put in is 100% correct, I've checked a few times.

Any ideas here?

Answer Source

The "mini-guide" uses the key "Client-ID" instead of "ClientID"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download