Ariel Gemilang
Ariel Gemilang

Reputation: 791

Send Array as Parameter in Alamofire Swift 3

I'm trying to make array as parameter but the result is never success.

Here's my parameters:

let params: [String: Any] = [

        "debug": "1",
        "check_in": checkIn,
        "check_out": checkOut,
        "theme": theme,
        "beds": Beds,
        "bedrooms": Bedroom,
        "bathrooms": Bathroom,
        "facility": idFacility,
        "room_type": id,
        "page": 1,
        "take": 10,
        "id_user": sessionId
    ]

    print(params)
    print("THE PARAMS")

if my parameter printed:

[
 "take": 10, 
 "page": 1, 
 "debug": "1", 
 "id_user": 103, 
 "theme": [17, 18, 19], 
 "check_in": "2017-04-01", 
 "check_out": "2017-04-02", 
 "bedrooms": 1, 
 "beds": 1, 
 "room_type": [5, 6, 7], 
 "facility": [11, 12, 13], 
 "bathrooms": 1]

i don't understand, if i send single string or integer it works. But if array, response.result.value never success. I also try to add [String: Any] and still doesn't work.

Upvotes: 0

Views: 1267

Answers (1)

Ariel Gemilang
Ariel Gemilang

Reputation: 791

i solved it using:

let params: [String: Any] = [

        "debug": "1",
        "city": city,
        "check_in": checkIn,
        "check_out": checkOut,
        "max_guest": maxGuest,
        "theme": String(describing: theme),
        "currency": "IDR",
        "price_min": priceMinimum,
        "price_max": priceMaximum,
        "beds": Beds,
        "bedrooms": Bedroom,
        "bathrooms": Bathroom,
        "facility": String(describing: idFacility),
        "room_type": String(describing: id),
        "page": 1,
        "take": 10,
        "id_user": sessionId
    ]

    print(params)
    print("THE PARAMS")

Upvotes: 1

Related Questions