Hi i am using latest moya. i want to ask how to put header field ?, i am trying like this one but always return 400. If my way is correct probably the header content is wrong.. Just want to make sure
let endpointClosure = { (target: API) -> Endpoint<API> in
let defaultEndpoint = RxMoyaProvider.defaultEndpointMapping(target)
return defaultEndpoint.adding(newHttpHeaderFields: ["Accept": "application/json", "Content-Type" : "application/json", "Authorization" : token!, "X-Fingi-Signature":authSign as String])
}
self.provider = RxMoyaProvider<API>(endpointClosure: endpointClosure)
@abadikaka You can use the NetworkLoggerPlugin to make sure your requests are being sent as expected:
self.provider = RxMoyaProvider<API>(endpointClosure: endpointClosure,
plugins: [NetworkLoggerPlugin(verbose: true)])
This will log details about every request :wink:
Thanks @pedrovereza !.. Yes my body request somehow is not correct... and the parameters encoding i need use JSONEncoding but it need to be set in the endpointclosure.. Thank you it very helps me
Most helpful comment
@abadikaka You can use the
NetworkLoggerPluginto make sure your requests are being sent as expected:This will log details about every request :wink: