View difference between Paste ID: KTFF0cBP and HmGDxRsz
SHOW: | | - or go back to the newest paste.
1
import requests
2
3
# this works, I get valid results
4
response = requests.get(
5
    url =  'https://www.strava.com/api/v3/athlete/activities',
6
    headers = {'Authorization': 'Bearer ' + access_token},
7
)
8
response.raise_for_status()
9
print(response.text)
10
11
##############################################################################
12
# result of above call:
13
[{"resource_state":2,"athlete":{"id":
14
##############################################################################
15
16
# this does not work
17
response = requests.get(
18
    url =  'https://www.strava.com/api/v3/athlete/activities',
19
    headers = {'Authorization': 'Bearer ' + access_token},
20
    data = {
21
        'page' : '1'
22
    }
23
)
24-
                                
24+
25-
# result of above call:\
25+
26
27
################################################################################################                              
28
# result of above call:
29
---------------------------------------------------------------------------
30
HTTPError                                 Traceback (most recent call last)
31
<ipython-input-79-3bc18d072030> in <cell line: 0>()
32
     15     }
33
     16 )
34
---> 17 response.raise_for_status()
35
     18 print(response.text)
36
37
/usr/local/lib/python3.11/dist-packages/requests/models.py in raise_for_status(self)
38
   1022 
39
   1023         if http_error_msg:
40
-> 1024             raise HTTPError(http_error_msg, response=self)
41
   1025 
42
   1026     def close(self):
43
44
HTTPError: 403 Client Error: Forbidden for url: https://www.strava.com/api/v3/athlete/activities
45
####################################################################################################
46
  
47
#####################################################################################################
48
# if I delete the "response.raise_for_status()" line, I get this result:
49
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
50
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
51
<TITLE>ERROR: The request could not be satisfied</TITLE>
52
</HEAD><BODY>
53
<H1>403 ERROR</H1>
54
<H2>The request could not be satisfied.</H2>
55
<HR noshade size="1px">
56
Bad request.
57
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
58
<BR clear="all">
59
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
60
<BR clear="all">
61
<HR noshade size="1px">
62
<PRE>
63-
</BODY></HTML>
63+
64
Request ID: 6CW002TGMQM-doqB1bDDAAMhWht935crS4hSt_4vvz8NDCsceVVMtg==
65
</PRE>
66
<ADDRESS>
67
</ADDRESS>
68
</BODY></HTML>
69
#########################################################################################################