Moya: How/where to set the HTTP JSON body, Error: Response: Received empty network response for
my moya config
public var method: Moya.Method {
switch self {
case .uploadPictureTest:
return .GET
case .register:
return .POST
case .login:
return .POST
}
}
public var parameterEncoding: Moya.ParameterEncoding {
switch self {
case .register:
return ParameterEncoding.JSON
default:
return ParameterEncoding.Custom(MyAPICallCustomEncodingClosure)
}
}
get this errror
Moya_Logger: [11/09/2016 15:53:17] Request: <NSMutableURLRequest: 0x7f801492de90> { URL: http://test.fragment.com.cn/rest/phone_register/new }
Moya_Logger: [11/09/2016 15:53:17] Request Headers: ["X-ApiKey": "xxx", "Content-Type": "application/json"]
Moya_Logger: [11/09/2016 15:53:17] HTTP Request Method: POST
Moya_Logger: [11/09/2016 15:53:17] Request Body: {"country_code":"86","phone":18815289863}
Moya_Logger: [11/09/2016 15:53:17] Response: Received empty network response for register("86", 18815289863).
How to solve this problem, thanks
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (8 by maintainers)
I solve it , it is my mistake .
will get this error use static or shareInstance
I did use “.requestParameters(parameters: parameters!, encoding: JSONEncoding.default)” but this code was running before the XCode11 update 😃 Interesting error
I have removed the API key, just to avoid tempering with it. Next time, you can just leave your issue open after editing its content / title 😃