我有如下Http正文

Subject=Example
[MSISDN]
List=+44777123123,+44777123124,+44777123125
[MESSAGE]
Text=A SAMPLE SMS to three mobile phones.
[SETUP]
MobileNotification=YES
[END]

我想发布它的服务器,但我无法找出我如何正确翻译身体。我在用阿拉莫菲尔图书馆。我试过了
let parameters:[String:AnyObject] = [
        "Subject"   : "Example",
        "MSISDN"    : [
            "List" :["+905555555555"]
        ],
        "MESSAGE"   : [
            "Text" : "Test text bla bla bla"
        ],
        "SETUP"     : [
            "MobileNotification": "YES",
            "OriginatorPort"    : "1581"
        ]
    ]


let parameters:[String:AnyObject] = [
        "Subject"   : "Example",
        "List"      :["+905555555555"],
        "Text"      : "Test text bla bla bla",
        "MobileNotification" : "YES"
    ]

但我收到了400个坏请求。
Alamofire.request(.POST, URL, headers: headers, parameters: parameters)
            .responseString{ response  in
                print(response.debugDescription)
                print(response.response?.statusCode)
                print(response.request?.allHTTPHeaderFields)
                switch response.result {
                case .Success:
                    print(response.request?.HTTPBody)
                case .Failure(let error):
                    print(error)
                }
        }

最佳答案

像这样的:

let parameters:[String:AnyObject] = [
    "Subject"   : "Example",
    "MSISDN"    :["+44777123123","+44777123124","+44777123125"],
    "MESSAGE"   : "A SAMPLE SMS to three mobile phones.",
    "MobileNotification" : "YES"
]

关于swift - Swift HTTP正文转换,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39618228/

10-11 18:04