Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

GET http request with header parameters

Hi everyone, In order to retrieve the rhymes of a given word, I have to make the following GET request:

GET "https://wordsapiv1.p.mashape.com/words/word/rhymes" -H "X-Mashape-Key: myKey" -H "Accept: application/json"

I can't figure out how to make this GET request in swift. I've also tried to make "swiftHTTP" to work, as explained here:

https://github.com/daltoniam/SwiftHTTP

but I am not able to link the external framework.

Anyone could help me making that GET request?

1 Answer

Take a look at the NSMutableURLRequest's header setting methods in the docs