При звонке с использованием Alamofire я хотел бы проверить ответ от сервера. Ответ сервера с { status code 400, Headers {
но не показывает остальную информацию. Что это значит? У меня высокая склонность к тому, что проблема связана с моими заголовками, но я не уверен, что именно.
class func missionOne(){
let authorizationPath: String = "https://belivedev.restv2.eastus.media.azure.net/api/Channels"
if let authorizationURL: URL = URL.init(string: authorizationPath){
let parameters: [String : Any] = [
"Name": "iOS-test-channel-1",
"Description": "My channel description for use in discovery",
"Input": [
"KeyFrameInterval": "",
"StreamingProtocol": "FragmentedMP4",
"AccessControl": ["IP": ["Allow": [
[
"Name": "Allow All",
"Address": "0.0.0.0",
"SubnetPrefixLength": ""
]
]]],
"Endpoints": []
],
"Preview": [
"AccessControl": ["IP": ["Allow": [
[
"Name": "Allow All",
"Address": "0.0.0.0",
"SubnetPrefixLength": ""
]
]]],
"Endpoints": []
],
"Output": ["Hls": ["FragmentsPerSegment": 1]],
"CrossSiteAccessPolicies": [
"ClientAccessPolicy": "",
"CrossDomainPolicy": ""
]
]
guard let bearerToken = AzureMediaServicesAPIManager.sharedInstance.authToken else { return }
let headers = [
"x-ms-version": "2.15",
"Accept": "application/json",
"Content-Type": "application/json",
"DataServiceVersion": "3.0",
"MaxDataServiceVersion": "3.0",
"User-Agent": "azure media services postman collection",
"Authorization": "Bearer \(bearerToken)",
"Host" : "https://rest.media.azure.net"
]
Alamofire.request(authorizationURL, method: .post, parameters: parameters, encoding: URLEncoding.default, headers: headers)
.debugLog()
.validate(statusCode: 200..<300)
.responseJSON { response in
switch response.result {
case .failure(let error):
print(error.localizedDescription)
print("We hit the failure switch statement \(error.localizedDescription)")
print("The url request sent to the server is: \(response.request)")
print("The response sent back from the server is: \(response.response)")
return
case .success:
print("Validation Successful")
}
}
}
}
}