Ich versuche, SMS über Plivo SMS API zu senden. Obwohl die HTTP-Methode für die Anforderung "POST" lautet, wird die Anfrage leider als "GET" gesendet. Bitte beachten Sie meinen Code unten.HTTP-Anfrage unter Verwendung der Standardmethode GET anstelle von POST
let fromNumber = "11111111111"
let toNumber = "111111234"
let message = "Hello"
do {
let json = ["src":"\(fromNumber)","dst":"\(toNumber)","text":"\(message)"]
let jsonData = try NSJSONSerialization.dataWithJSONObject(json, options: NSJSONWritingOptions.PrettyPrinted)
print(jsonData)
// Build the request
let request = NSMutableURLRequest(URL: NSURL(string:"https://"\(authId)":"\(authToken)"@api.plivo.com/v1/Account/"\(authId)"/Message")!)
// I'm assigning the method should be 'POST' but why its going as 'GET'
request.HTTPMethod = "POST"
request.HTTPBody = jsonData
// Build the completion block and send the request
let task = NSURLSession.sharedSession().dataTaskWithRequest(request){ data, response, error in
if error != nil{
print("Error -> \(error)")
return
}
do {
let result = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as? [String:AnyObject]
print("Result -> \(result)")
} catch {
print("Error -> \(error)")
}
}
task.resume()
//return task
} catch {
print(error)
}
}
Bitte schauen Sie auf den Screenshot, die Anfrage als 'GET' Anfrage geschrieben.Bitte helfen Sie mir, dieses Problem zu lösen.