Search code examples
swifthttp-headersalamofirehttp-status-code-400

What does an open bracket signify when using Alamofire to inspect a server response?


enter image description here

When making a call using Alamofire, I'd like to inspect the response from the server. The server response with { status code 400, Headers { but doesn't show the rest of the information. What does this mean? I have a high inclination that the problem is with my headers but I'm not sure what it is specifically.

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")
                        }
                    }
            }
    }

}

Solution

  • Your filter at the bottom of the console for the response is only showing the lines that contains that string. It looks the the description for that object contains new lines which are being hidden by the filter.

    Remove the filter and scroll to the line in the console output, or do a find to search through the output.