gpt4 book ai didi

swift - 将锻炼参数上传到 Strava - Swift

转载 作者:行者123 更新时间:2023-11-28 07:29:26 27 4
gpt4 key购买 nike

我正在尝试通过我的应用程序将我的锻炼上传到 strava & 当我发送我的请求时它返回我并显示错误 400 和这个:

(String?) $R0 = "{\"message\":\"Bad Request\",\"errors\":[{\"resource\":\"Upload\",\"field\":\"file\",\"code\":\"not a file\"}]}"

我能够毫无问题地将我的应用程序连接到 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)
}
}

最佳答案

根据 Strava API 文档 ( https://developers.strava.com/docs/uploads/ ),file 字段是必需的,看起来您已将其设置为 nil。这可能就是它返回 not a file 的原因,因为没有文件通过。

关于swift - 将锻炼参数上传到 Strava - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55343998/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com