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

Use moya to send POST request with json but no http body send #2313

Open
lzz212 opened this issue Jun 9, 2023 · 0 comments
Open

Use moya to send POST request with json but no http body send #2313

lzz212 opened this issue Jun 9, 2023 · 0 comments

Comments

@lzz212
Copy link

lzz212 commented Jun 9, 2023

I use moya 15 to do network jobs.
And I need send a http request with json but I use the Charles to get the http package and find that no body.

public var task: Task {
    switch self {
    case let .loginGetSMS(phone):
        var params = [String: Any]()
        params["phone"] = phone
        var urlParams = [String: Any]()
        urlParams["phone"] = phone

// return .requestParameters(parameters: params, encoding:JSONEncoding.default)
return .requestCompositeParameters(bodyParameters: params,
bodyEncoding: JSONEncoding.default,
urlParameters: [:])

.....
I use these two ways to send both no use.
But when I change the encoding from JSONEncoding to URLEncoding server can see the body but not json

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

No branches or pull requests

1 participant