“Swift Alamofire X-WWW-FORM-URLENCODED” Ответ

Swift Alamofire X-WWW-FORM-URLENCODED

let param:Parameters=[
        "param":param]
   let headers:HTTPHeaders=[
        "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"]
    
    Alamofire.request(url,method: .post,parameters: param,encoding: URLEncoding.httpBody, headers: headers).responseJSON{response in
....
 }
Enthusiastic Echidna

Swift Alamofire X-WWW-FORM-URLENCODED

let headers = [
    "Content-Type": "application/x-www-form-urlencoded"
]
let parameters = [
    "myParameter": "value"
]
let url = NSURL(string: "https://something.com")!
Alamofire.request(.POST, url, parameters: parameters, headers: headers, encoding: .URLEncodedInURL).response { request, response, data, error in
    print(request)
    print(response)
    print(data)
    print(error)
}
Enthusiastic Echidna

Swift Alamofire X-WWW-FORM-URLENCODED

let parameters: [String: [String]] = [
    "foo": ["bar"],
    "baz": ["a", "b"],
    "qux": ["x", "y", "z"]
]

// All three of these calls are equivalent
AF.request("https://httpbin.org/post", method: .post, parameters: parameters)
AF.request("https://httpbin.org/post", method: .post, parameters: parameters, encoder: URLEncodedFormParameterEncoder.default)
AF.request("https://httpbin.org/post", method: .post, parameters: parameters, encoder: URLEncodedFormParameterEncoder(destination: .httpBody))

// HTTP body: "qux[]=x&qux[]=y&qux[]=z&baz[]=a&baz[]=b&foo[]=bar"
Enthusiastic Echidna

Ответы похожие на “Swift Alamofire X-WWW-FORM-URLENCODED”

Вопросы похожие на “Swift Alamofire X-WWW-FORM-URLENCODED”

Больше похожих ответов на “Swift Alamofire X-WWW-FORM-URLENCODED” по Swift

Смотреть популярные ответы по языку

Смотреть другие языки программирования