2016-09-21 40 views
1

我有HTTP正文如下雨燕HTTP主體轉換

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

我要發佈它的服務器,但我無法弄清楚如何正確翻譯機構。我正在使用Alamofire庫。我試圖

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

回答

0

事情是這樣的:

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

6017的格式錯誤或在部分消息字段的文本缺少強制值。 – aahmetbas

+0

我認爲它的SAP Web服務,你必須以XML格式發送請求! –

+0

是的,它是SAP servis,但它是HTTP接口 – aahmetbas