Moya: Is my way to put header to Moya correct format ?

Created on 8 Feb 2017  路  2Comments  路  Source: Moya/Moya

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)
question

Most helpful comment

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

All 2 comments

@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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

syq7970 picture syq7970  路  3Comments

pedrovereza picture pedrovereza  路  3Comments

Tynox picture Tynox  路  3Comments

JianweiWangs picture JianweiWangs  路  3Comments

ghost picture ghost  路  3Comments