I want to send more than one "davetiyeID". For this, I send the DAVMED_ID array as a parameter. But when printing, I get blank output. What do I need to do to send more than one value? So I want to send more than one davetiyeID. Is it possible for me to do this? Can I send 3-4 invitation IDs instead of one davetiyeID?
extension Array {
/// Convert the receiver array to a `Parameters` object.
func asParameters() -> Parameters {
return [arrayParametersKey: self]
}
}
var DAVMED_ID : [String] = []
public struct ArrayEncoding: ParameterEncoding {
public let options: JSONSerialization.WritingOptions
public init(options: JSONSerialization.WritingOptions = []) {
self.options = options
}
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
var urlRequest = try urlRequest.asURLRequest()
guard let parameters = parameters,
let array = parameters[arrayParametersKey] else {
return urlRequest
}
do {
let data = try JSONSerialization.data(withJSONObject: array, options: options)
if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil {
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
}
urlRequest.httpBody = data
} catch {
throw AFError.parameterEncodingFailed(reason: .jsonEncodingFailed(error: error))
}
return urlRequest
}
}
@objc func favKontrol(){
let url = URL(string: "...")!
var request = URLRequest(url: url)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
Alamofire.request(
url,
method: .post,
parameters: DAVMED_ID.asParameters(),
encoding: ArrayEncoding(),
headers: nil).responseJSON { (responseData) -> Void in
switch (responseData.result) {
case .success(let result):
...
}