unogsNG

פרמיום
על ידי Admin | מְעוּדכָּן hace 13 días | Media
פּוֹפּוּלָרִיוּת

9.7 / 10

חֶבִיוֹן

515ms

רמת שירות

100%

Health Check

N/A

חזרה לכל הדיונים

Swift code snippet only returns headers not body

Rapid account: Stuartcrawford
stuartcrawford
hace 3 años

I am brand new to both rapidapi and Swift. I’m trying to test a simple query that lists all of current Netflix countries. I paste the Swift code snippet into my Swift IDE and it runs successfully. However when the response is printed out it shows only the headers, not the actual body of the response. Any ideas? Thanks in advance – here is the code snippet:

import Foundation

let headers = [
“x-rapidapi-host”: “unogsng.p.rapidapi.com”,
“x-rapidapi-key”: “df44e4d070mshe820a364eeca52fp132678jsn162eb831ee2d”
]

let request = NSMutableURLRequest(url: NSURL(string: “https://unogsng.p.rapidapi.com/countries”)! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})

dataTask.resume()

Rapid account: Unogs
unogs Commented hace 3 años

Can’t really help, as I don’t know swift… but you should really remove your private key from this PUBLIC post!

הצטרף לדיון - הוסף תגובה למטה:

התחבר / הירשם כדי לפרסם תגובות חדשות