ecobee-api

Converting ecobee Alamofire request to use URLSession

随声附和 提交于 2019-12-25 03:29:18
问题 As a followup to my last question (Alamofire syntax for ecobee request), I would prefer to just use URLSession for the request. Now I'm back to a request that times out with status 408 using the following code: guard let url = URL(string: "https://api.ecobee.com/1/thermostat") else { return } let jsonParameters = [ "selection": [ "selectionType": "registered", "selectionMatch": "" ] ] let jsonData = try! JSONEncoder().encode(jsonParameters) let jsonString = String(decoding: jsonData, as: UTF8

Alamofire syntax for ecobee request

旧街凉风 提交于 2019-12-11 15:19:00
问题 I'm trying to find the correct syntax for calling ecobee's API from Swift 4 using Alamofire. Their cURL example: curl -H "Content-Type: text/json" -H "Authorization: Bearer ACCESS_TOKEN" 'https://api.ecobee.com/1/thermostat?format=json&body=\{"selection":\{"selectionType":"registered","selectionMatch":"","includeRuntime":true\}\}' The closest I've been to a solution is this func doRequest() { guard let url = URL(string: "https://api.ecobee.com/1/thermostat?format=json") else { return } let