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
How can we pass default null value or null value as a value in parameter list of dictionary [String:String] while posting a request using Alamofire ?
#2407
Closed
BugFinder27 opened this issue
Jan 5, 2018
· 5 comments
I don't think this is an Alamofire issue.. or is this is even a issue?
You simply can not putt nil value in dictionary in siwft. your server side should handle this if you don't send specific key in your request, your server should assume it as nil or put any default value.
@AfrozZaheer is correct, the [String: Any] type Alamofire uses for its parameters accepts optional values just fine, and those are encoded into JSON null values automatically if they're nil. We may update the signature of Parameters to [String: Any?] in the future just to make it more clear.
It doesn't seem that this issue has been resolved and I don't believe the above comment is correct anymore. If I create a standard project and just try to make a request with nil values, I can see that the UrlEncodedFormEncoder does not accept nil values. Also @AfrozZaheer and @jshier being able to send nil values is a very common requirement for APIs. You use them all the time with PATCH endpoints, and not sending the field is unexpected since a PATCH endpoint expects to update only fields that are in the request. This a standard workflow that Alamofire should be able to handle. I brought it up with my backend engineers and they were surprised at how difficult this is to do with Alamofire. Please let me know if there is an elegant way of doing this with the current version of Alamofire or please re-open this issue.
@JKnight3517 This really doesn't have anything to do with the original issue. Please open a new issue for the feature request and we can investigate there.
No description provided.
The text was updated successfully, but these errors were encountered: