gtalarico / pyairtable

Python Api Client for Airtable
https://pyairtable.readthedocs.io
MIT License
765 stars 138 forks source link

configurable api_base_url #243

Closed goksan closed 1 year ago

goksan commented 1 year ago

Adds configurable api_base_url when creating Api

api = Api(token, api_base_url="https://api.airwalker.io/")

airtable.js implements this as endpointUrl https://github.com/Airtable/airtable.js/blob/2d36eb64249a51e99cc7f2ea3dfb59cd3522a188/README.md?plain=1#L68

codecov-commenter commented 1 year ago

Codecov Report

Merging #243 (14e5d49) into main (2f6ecd6) will increase coverage by 0.05%. The diff coverage is 83.33%.

@@            Coverage Diff             @@
##             main     #243      +/-   ##
==========================================
+ Coverage   87.34%   87.40%   +0.05%     
==========================================
  Files          14       14              
  Lines         640      643       +3     
==========================================
+ Hits          559      562       +3     
  Misses         81       81              
Impacted Files Coverage Δ
pyairtable/metadata.py 40.00% <0.00%> (ø)
pyairtable/api/api.py 76.31% <66.66%> (ø)
pyairtable/api/abstract.py 100.00% <100.00%> (ø)
pyairtable/api/base.py 78.37% <100.00%> (ø)
pyairtable/api/table.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

mesozoic commented 1 year ago

Thanks for submitting this patch and working through revisions! ❤️ Due to commit signing requirements on this repository, I've squashed and merged this branch into main as 0189d9d.

goksan commented 1 year ago

@mesozoic

There is a regression between our versions caused by the endpoint_url assignment difference.

Here's a snippet that produces an error on main (a valid token, base id and table id is used, I just removed them to share this here):

from pyairtable import Api
token = "TOKEN"
api = Api(token, endpoint_url="https://api.airwalker.io")
table = api.get_table('BASEID', 'TABLEID').create({"Task": "aaa"})
line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: ('405 Client Error: Method Not Allowed for url: https://api.airwalker.io/v0/v0/BASEID/TABLEID', '405 Client Error: Method Not Allowed for url: https://api.airwalker.io/v0/v0/BASEID/TABLEID')