I am not aware of building api with dynamic values.I have an api and from that, i want to get pluscode by sending url request with latitude, longitude and email to base url.My requirement is sending request in get method with lat,long and email values and getting pluscode from response.Can anyone help me to build this url.
lat = locValue.latitude
long = locValue.longitude
email = abcdefg@gmail.com
//base url
var pluscodeurl = "https://plus.codes/api?address="
let postParameters = ["address":lat+long ,"email":"mahithaa.angadi@gmail.com"] as [String : Any]
Alamofire.request(pluscodeurl, method: .get, encoding: URLEncoding.default, headers: nil).responseJSON { response in
switch response.result {
case .success:
print(response)
case .failure(_):
break
}
}
Here is the snippet you can write it
let lat = "19.0760"
let long = "72.8777"
let email = "abc@test.com"
let ApiURL = "https://plus.codes/api?address=\(lat),\(long)&email=\(email)"
Alamofire.request(ApiURL).responseJSON { response in
print("Result: \(response.result)")
if let json = response.result.value {
print("JSON: \(json)")
}
if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) {
print("Data: \(utf8Text)")
}
}
You can write your url in the below format:
let email = "abc@gmail.com"
let pluscodeurl = "https://plus.codes/api?address=\(lat),\(long)&email=\(email)"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.