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 trialSebastian Nilsson
1,778 PointscURL in swift
Hi,
i am currently learning about swift and ar trying to build as much of small apps to get me up to spead.
i am currently developing a small IoT application for use with onion omega cloud.
i have a small cURL string that i am trying to convert to swift but arent finding the right solution to get it to work.
is there anyone who can guide me in the right path?
i attached the cURL command below.
curl -H "Content-Type: application/json" -H "X-API-KEY: <Your_Api_Key>" -X POST -d '{"command":"set","params":{"channel":"0","state":"off","address":"000"}}' https://api.onion.io/v1/devices/a1XXXXX-XX2-XXXXX-XX14-XXXXXXXX/i2c_exp/relay-exp
//Sebastian
1 Answer
Enara L. Otaegi
13,107 PointsYou need to use the URLSession API, also you can take a look at Alamofire that is an HTTP networking library made in Swift.