简体   繁体   中英

Swift 3 : Alamofire POST request parameters issue

I'm using Alamofire for using POST request. But I can't fill the OrderDetails items in parameters as you can see the code below. I post everything except OrderDetails items. Can you see what is the problem?

I put this code in for in loop.

 let parameters: Parameters = ["UserId": 1,
                                              "CompanyId":id,
                                              "TableNumber":tableNumber ,
                                              "Description":all.details!,
                                              "OrderDetails": [
                                                "MenuItemId":Int(all.menuID!)!,
                                                "Piece":all.count!,
                                                "Description":all.customerDetails!
                    ]
                ]

You could try this on your swift,

let parameters: [String:Any] = ["UserId": 1,
                                  "CompanyId":1,
                                  "TableNumber":2 ,
                                  "Description":3,
                                  "OrderDetails": "{'MenuItemId':4,'Piece':5,'Description':2}"
]

and handle post data like this;

$OrderDetails = json_decode($_POST['OrderDetails'],true);

now you can, get your values from $OrderDetails

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM