Alamofire parameters personnalisés

J'essaye de convertir cet appel de boucle à Alamofire dans Swift.

curl -X POST https://content.dropboxapi.com/2/files/download --header "Authorization: Bearer ab-xxx-xx" --header "Dropbox-API-Arg: {\"path\": "/acme101/acmeX100/acmeX100.001.png\"}" 

Et j'ai pensé ça …

 let headers:HTTPHeaders = ["Authorization": "Bearer " + token2Save] let moreheaders:Parameters = ["Dropbox-API-Arg": ["path":sourcePath]] Alamofire.request("https://content.dropboxapi.com/2/files/download", parameters: moreheaders, encoding: URLEncoding(destination: .querySsortingng), headers: headers).responseJSON { feedback in guard feedback.result.value != nil else { print("Error: did not receive data", print("request \(request) feedback \(feedback)")) return } 

Mais bien sûr ça ne marche pas, ça plante avec …

 request (Function) feedback FAILURE: responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.})) Error: did not receive data () 

Cela doit être dans l'en-tête, pas dans le corps.

 let headers:HTTPHeaders = ["Authorization": "Bearer " + token2Save] let moreheaders:Parameters = ["Dropbox-API-Arg": ["path":sourcePath]] Alamofire.request("https://content.dropboxapi.com/2/files/download", parameters: moreheaders, encoding: URLEncoding(destination: .querySsortingng), headers: headers).responseJSON { feedback in guard feedback.result.value != nil else { print("Error: did not receive data", print("request \(request) feedback \(feedback)")) return 

URLEncoding (destination: .querySsortingng), en-têtes: en-têtes) .responseJSON

  Replace responseJSON with responseSsortingng and check your response from webservice.. it will lead to get the error line.