我试图在我的应用中使用Alamofire进行API调用,但是我收到了一个奇怪的错误。
'There was an error deserializing the object of type Tucson.Geocaching.WCF.API.CreateTrackableLogRequestV1. DateTime content '\/Date(1452942271163+0500)\/' does not start with '\/Date(' and end with ')\/' as required for JSON.'
在Website of the API上,它说日期格式必须如下:"\/Date(928174800000-0700)\/"
我的代码:
postTBLog("GSYCNP", text: "Test", date: "\\/Date(928174800000-0700)\\/", logType: 48)
func postTBLog (code: String, text: String, date: String, logType: Int) -> Bool {
if let apiKey = apiKey {
let url = "https://api.groundspeak.com/LiveV6/geocaching.svc/CreateTrackableLog"
let parameters:[String : AnyObject] = ["AccessToken":apiKey, "TrackingNumber":code, "UTCDateLogged": date, "Note":text, "LogType":logType]
Alamofire.request(.POST, url, parameters: parameters, encoding: .JSON).responseString { response in
print(response)
}
return true
} else {
return false
}
}
我已经尝试了不同的东西,但没有任何工作。如果你可以帮助我,我会很高兴,谢谢。
答案 0 :(得分:0)
在我将"\\/Date(928174800000-0700)\\/"
转为"/Date(928174800000)/"