Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
Assignees
Labels

Comments

@BugFinder27
Copy link

No description provided.

@AfrozZaheer
Copy link

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.

@jshier
Copy link
Contributor

jshier commented Jan 22, 2018

@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.

@JKnight3517
Copy link

JKnight3517 commented Jul 12, 2022

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.
Screen Shot 2022-07-12 at 11 53 47 AM

@jshier
Copy link
Contributor

jshier commented Jul 12, 2022

@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.

@JKnight3517
Copy link

@jshier , sounds good I opened up a feature request 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants