I need a URL like this to work:
Code I used to generate the URL:
let wktStr: String = "POINT("+formattedX+"%"+formattedY+")"
var components = URLComponents()
components.scheme = "https"
components.host = "somehost.gov"
components.path = "/api/wtk_download.csv"
components.queryItems = [
URLQueryItem(name: "api_key", value: "DEMO_KEY"),
URLQueryItem(name: "wkt", value: wktStr),
URLQueryItem(name: "attributes", value: "power"),
URLQueryItem(name: "names", value: yearString),
URLQueryItem(name: "interval", value: "60"),
URLQueryItem(name: "full_name", value: "SampleUser"),
URLQueryItem(name: "email", value: "sample@email.com"),
URLQueryItem(name: "affiliation", value: "TestOrganization"),
URLQueryItem(name: "reason", value: "Dev")
]
let url = components.url
print(url!)
print(url!.absoluteURL)
Prints:
The server host gives an error because the POINT(-104.23828125%252039.90973623454) has %25 instead of just %.
How can I generate the item POINT(-104.23828125%2039.90973623454) which has just the %?