list_budget_rules return 200OK, but when run flask to create new API endpoint it shows: "TypeError: list_budget_rules() missing 2 required positional arguments: 'nextToken' and 'pageSize'" #197
Replies: 3 comments 2 replies
-
Could you please share your function to call the endpoint? some endpoints in general return a subset of data based on the pagesize parameter, e.g. there are enough data as 200 results but the maximum pagesize is 10, the first request returns a nextToken which is necessary to use to complete the data collection. You can set your own pageSize or the endpoint will use the default of the api endpoint, but if the total result data is over the pageSize it will return in the payload nextToken that you will need to use in the next request to get the following subset, eg: first call returns for 1 to 10, second, from 11 -20,....and so on This is very easy to deal with a decorator like in the Utils: @Utils.load_all_pages(throttle_by_seconds=1, next_token_param="nextToken") |
Beta Was this translation helpful? Give feedback.
-
The client supports proxy:
proxies: Optional[Dict[str, str]] = None,
But in last term it delegates in the library request:
from requests import request
r = requests.get(
location,
headers=headers or self.headers,
data=None,
allow_redirects=True,
timeout=self.timeout,
proxies=self.proxies,
verify=self.verify,
)
So it will pass whatever you set when creating your client:
my_proxies = {
'http': 'http://10.10.1.10:3128',
'https': 'https://10.10.1.11:1080',
}
try:
result = sponsored_products.Campaigns(account=store, marketplace=marketplace, proxies=my_proxies, debug=True).list_campaigns_extended(
)
campaigns = result.payload
except AdvertisingApiException as error:
logging.info(error)
Kindest regards,
Daniel
… El 28 abr 2024, a las 20:48, giangdaughtry ***@***.***> escribió:
I got it. Thank you. Now, Im facing the issue for the CORS. I setup a proxy at localhost:5000 for localhost:3000
Now i want to add into header of response from server.
('Access-Control-Allow-Origin', '')
('Access-Control-Allow-Headers', '')
('Access-Control-Allow-Methods', '*')
How can I do this?
For example: GET method of:
@sp_endpoint('/sp/budgetRules', method='GET')
def list_budget_rules(self, **kwargs) -> ApiResponse:
—
Reply to this email directly, view it on GitHub <#197 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AD4ENUR7KWCIJPJEYVN4ROLY7TVZZAVCNFSM6AAAAABG3RLLDKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TENJSGA2DO>.
You are receiving this because you commented.
|
Beta Was this translation helpful? Give feedback.
-
Now I am creating REACT front end to handle POST fetch API to create new budget rule. I am thinking of using Flask. But I dont know how to transfer values from inputs front end to make a POST fetch.
|
Beta Was this translation helpful? Give feedback.
-
Hello everyone,
I already made a successful list_budget_rules request following your template. And get 200OK with payload:
// now in my amazon ad account dont have any budget rules.
'payload': {'budgetRulesForAdvertiserResponse': [], 'nextToken': None}}
But when I run a flask to shows the result in payload, it get the error:
Traceback (most recent call last):
File "D:\BUSINESS\MMO\AMZ\FBA\AmzAds\AMS Project\python-amazon-ad-api.venv\Lib\site-packages\flask\app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\BUSINESS\MMO\AMZ\FBA\AmzAds\AMS Project\python-amazon-ad-api.venv\Lib\site-packages\flask\app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\BUSINESS\MMO\AMZ\FBA\AmzAds\AMS Project\python-amazon-ad-api.venv\Lib\site-packages\flask\app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\BUSINESS\MMO\AMZ\FBA\AmzAds\AMS Project\python-amazon-ad-api.venv\Lib\site-packages\flask\app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: list_budget_rules() missing 2 required positional arguments: 'nextToken' and 'pageSize'
2024-04-27 05:59:21,571:INFO:127.0.0.1 - - [27/Apr/2024 05:59:21] "GET /sp/list_budget_rules HTTP/1.1" 500 -
2024-04-27 05:59:21,723:ERROR:Exception on /sp/list_budget_rules [GET]
Traceback (most recent call last):
File "D:\BUSINESS\MMO\AMZ\FBA\AmzAds\AMS Project\python-amazon-ad-api.venv\Lib\site-packages\flask\app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\BUSINESS\MMO\AMZ\FBA\AmzAds\AMS Project\python-amazon-ad-api.venv\Lib\site-packages\flask\app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\BUSINESS\MMO\AMZ\FBA\AmzAds\AMS Project\python-amazon-ad-api.venv\Lib\site-packages\flask\app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\BUSINESS\MMO\AMZ\FBA\AmzAds\AMS Project\python-amazon-ad-api.venv\Lib\site-packages\flask\app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: list_budget_rules() missing 2 required positional arguments: 'nextToken' and 'pageSize
Beta Was this translation helpful? Give feedback.
All reactions