我试图在我的应用程序中使用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.'在空气污染指数网站上,它说日期格式必须如下:"\/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
}
}我已经试过了不同的东西,但没有缝好。如果你能帮我我会很高兴的,泰克斯。
发布于 2016-01-16 11:50:07
在我把"\\/Date(928174800000-0700)\\/"变成"/Date(928174800000)/"之后它就起作用了
https://stackoverflow.com/questions/34826432
复制相似问题