2

I have a POST API in which I send multiple parameters, one of those parameters has to be an array of dictionaries.

let arr = [
    [
        "id" : "1",
        "price" : "10"
    ],
    [
        "id" : "2",
        "price" : "20"
    ]
]
let params : Parameters = [

    "param1" : "anyvalue1",

    "param2" : "anyvalue2",

    "param3" : arr,

    ]

When I use these parameters in Alamofire Request and hit the API, print(res.result.value) always returns unknown. Can anyone help me with this. Following is the way of requesting the API

Alamofire.request(url, method:.post, parameters: params).responseJSON{(res) in print(res.result.value) //always shows 'unknown' as output }

Arasuvel
  • 2,971
  • 1
  • 25
  • 40
Ahsan Ebrahim Khatri
  • 1,807
  • 1
  • 20
  • 27

1 Answers1

0

Try to make params a Dic of [String :Any ] like that :

let params : [String:Any] = [

    "param1" : "anyvalue1",

    "param2" : "anyvalue2",

    "param3" : arr,

    ]
Muhammed
  • 584
  • 1
  • 11
  • 24