我正在尝试通过我的应用程序将我的锻炼上传到 strava 并且当我发送我的请求时它返回错误 400 并且这个:
(字符串?)$R0 = "{\"message\":\"Bad Request\",\"errors\":[{\"resource\":\"Upload\",\"field\":\"文件\",\"代码\":\"不是文件\"}]}"
我能够毫无问题地将我的应用程序连接到 strava。这是我到目前为止所做的:
func saveWorkout(_ workout: FirebaseWorkout, completion: @escaping (_ success: Bool, _ error: Error?) -> Void) {
let opts: [String: Any?] = [
"file": nil,
"name": workout.name
"description": nil,
"trainer": false,
"commute": false,
"dataType": ".gpx",
"externalId": workout.key
]
if self.isAuthorized && userSettings.membership.hasFullAccess {
workoutLib().analyticsEvent(kEventCategoryThirdParty, eventAction: "SAVE_WORKOUT", eventLabel: ThirdPartyApplication.strava.rawValue, eventValue: 1)
workoutLib().debugLog("Strava: Save Workout")
self.refreshTokenIfNeeded {
_ = self.oauthswift.client.post("https://www.strava.com/api/v3/uploads", parameters: opts as OAuthSwift.Parameters, success: { (_) in
workoutLib().debugLog("Strava: Save Workout Success")
completion(true, nil)
}) { (error) in
workoutLib().debugLog("Strava: Save Workout \(error.localizedDescription)")
completion(false, error)
}
}
} else {
completion(false, nil)
}
}