You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I'm trying to post a JSON array of objects to a server. I'm pretty sure that server side works perfectly because I'm interacting with it using android app I have created. I'd be very appreciate if you could help to solve the problem I have with creating the same app on iOS using swift+swithttp.
Here is the method I'm parsing an object to array[string: any].
public func toDictionary() -> [String: Any] {
var itemDic = [String: Any]()
itemDic["UserId"] = UserId
itemDic["SelectedItems"] = getSelectedItems()
return itemDic
}
private func getSelectedItems() -> [[String: Any]] {
var array = [[String: Any]]()
for item in getSelectedItems {
array.append(item.toDictionary())
}
return array
}
When I print toDictionary() result I can see in console the following output:
["UserId": 110021, "SelectedItems": [["AnswerId": 2, "ItemId": 1], ["AnswerId": 2, "ItemId": 4], ["AnswerId": 2, "ItemId": 7]]]
Here is the code how I post the object to the server
HTTP.POST(ServerApi.REPORT, parameters: model.toDictionary()) { response in
//process response
}
The UserId parameter is receiving but the SelectedItems always empty. Can you help me to undestend why this is happen and how can I fix it?
Thank you!!
The text was updated successfully, but these errors were encountered:
Hello. I'm trying to post a JSON array of objects to a server. I'm pretty sure that server side works perfectly because I'm interacting with it using android app I have created. I'd be very appreciate if you could help to solve the problem I have with creating the same app on iOS using swift+swithttp.
Here is the method I'm parsing an object to array[string: any].
When I print toDictionary() result I can see in console the following output:
["UserId": 110021, "SelectedItems": [["AnswerId": 2, "ItemId": 1], ["AnswerId": 2, "ItemId": 4], ["AnswerId": 2, "ItemId": 7]]]
Here is the code how I post the object to the server
HTTP.POST(ServerApi.REPORT, parameters: model.toDictionary()) { response in
//process response
}
The UserId parameter is receiving but the SelectedItems always empty. Can you help me to undestend why this is happen and how can I fix it?
Thank you!!
The text was updated successfully, but these errors were encountered: