401 error when connecting API in Python code
Hello,
I successfully ran the school API on the ‘Try it’ area and got the JSON result from an advanced list on the web page. But when I ran the sample Python code by filling the ‘subscription key’ , ‘access taken’, and ‘list_id’, I got a 401 status code, says “Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription.”
Did I missing something here?
Comments
-
Hi Jacob,
There can be a few reasons why you'd see this error, but the most common:
- The subscription key header (bb-api-subscription-key) is provided on the request, but the header value is not set or the header value is not a valid subscription key (possibly a typo).
- The subscription key is valid but it is not correct for the API you are calling (e.g. a “Standard APIs” subscription key being used for the Payments API).
In your case, I only see one subscription on your account, so I believe your issue might be the former. Please check that the request has correctly set that subscription key header.
2 -
TLDR: Update your config_file test_api_endpoint parameter to something you can open.
The API Python Code provided (see Git justein230\\BbApiConnector) is helpful for setting up your environment but dates out a test node that may not work for everyone. The default in the in the config_file (apps_secrets.json) is "test_api_endpoint": "https://api.sky.blackbaud.com/school/v1/roles"; which is 'invalid' for me and perhaps others. To see this in effect, try going directly to it--you'll see it holler back the same 401 code explicitly.
In your respective config_file, change it to something you do have access to (as seen within the Try Me sections of the API manual). For me, I notated the the original parameter as old_test_api_endpoint (just in case--you never know and it never hurts to have a backup/restore plan) and a replacement test_api_endpoint as
Was able to get a clear 200 and start making the calls I wanted with the BbApiConnector. Hopes this helps someone else!
-TCL
1
Categories
- All Categories
- 6 Blackbaud Community Help
- 211 bbcon®
- 1.4K Blackbaud Altru®
- 402 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 1.1K Blackbaud CRM™ and Blackbaud Internet Solutions™
- 15 donorCentrics®
- 360 Blackbaud eTapestry®
- 2.6K Blackbaud Financial Edge NXT®
- 655 Blackbaud Grantmaking™
- 576 Blackbaud Education Management Solutions for Higher Education
- 3.2K Blackbaud Education Management Solutions for K-12 Schools
- 940 Blackbaud Luminate Online® and Blackbaud TeamRaiser®
- 84 JustGiving® from Blackbaud®
- 6.7K Blackbaud Raiser's Edge NXT®
- 3.7K SKY Developer
- 248 ResearchPoint™
- 120 Blackbaud Tuition Management™
- 165 Organizational Best Practices
- 240 Member Lounge (Just for Fun)
- 34 Blackbaud Community Challenges
- 37 PowerUp Challenges
- 3 (Open) PowerUp Challenge: Grid View Batch
- 3 (Closed) PowerUp Challenge: Chat for Blackbaud AI
- 3 (Closed) PowerUp Challenge: Data Health
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Product Update Briefing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports+
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Email Marketing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Gift Management
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Event Management
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Home Page
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Query
- 796 Community News
- 3K Jobs Board
- 54 Blackbaud SKY® Reporting Announcements
- 47 Blackbaud CRM Higher Ed Product Advisory Group (HE PAG)
- 19 Blackbaud CRM Product Advisory Group (BBCRM PAG)

