如何使用python中的API更新Strava活动?

问题描述 投票:0回答:1

我正在尝试使用python更新Strava活动。我正在使用请求模块发送GET,POST和PUT请求。我正在尝试使用put更新我的活动,但我不断收到此错误

{'errors': [{'code': 'not found', 'field': '', 'resource': 'Activity'}],'message': 'Resource Not Found'}

我有写访问令牌,我创建了一个字典,其中包含我想更新的内容,但我仍然继续获得此回报。这是我用来尝试更新活动的代码行

updateActivty = requests.put(updatableActivity_url, headers=write_header, data=changeDescription, verify=False).json()

关于我在这里做错什么的任何想法?(对不起,如果我将此问题的格式设置错误,这是我在堆栈溢出时的第一篇文章)

python http python-requests put strava
1个回答
0
投票

我从docs中拉了这个,您是否尝试过做类似的事情?

from __future__ import print_statement
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint

# Configure OAuth2 access token for authorization: strava_oauth
swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'

# create an instance of the API class
api_instance = swagger_client.ActivitiesApi()
id = 789 # Long | The identifier of the activity.
body =  # UpdatableActivity |  (optional)

try: 
    # Update Activity
    api_response = api_instance.updateActivityById(id, body=body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling ActivitiesApi->updateActivityById: %s\n" % e)
© www.soinside.com 2019 - 2024. All rights reserved.