Ride Estimates Request - Bad Parameter - Alamofire - Swift


#1

Hi everyone,
I’ve been using alamofire for my requests, and my code for the requests are:
let headerRequest: HTTPHeaders = [“Authorization” : “bearer (token)”]

    let paramsRequest: Parameters = ["start_lat" : 37.7763,
                                     "start_lng" : -122.3918,
                                     "end_lat" : 37.7972,
                                     "end_lng" : -122.453,
                                     "ride_type" : "lyft"]
    
    
    Alamofire.request("https://api.lyft.com/v1/cost", method: .get, parameters: paramsRequest, encoding: JSONEncoding.default, headers: headerRequest).responseJSON { response in
        print(response.result.value)
    }

However, when I run the code I keep getting the same error message:
error = “bad_parameter”;
“error_detail” = (
{
“start_lat” = “Missing required parameter”;
},
{
“start_lng” = “Missing required parameter”;
}
What exactly does this error statement mean? On the docs it says that it’s a validation error, but I’m not sure how to fix this. Any suggestions?
Thank you,
Olivier


#2

I figured it out, supposed to use URL encoding, not JSON encoding.


#3

Glad to hear it, thanks for letting us know!

Best,
Josh


#4