fix 534: ループを使用してアプリの詳細情報を取得する

This commit is contained in:
Mouriya
2024-07-22 16:40:52 +09:00
parent c6a577b5ec
commit b9a7dd99da

View File

@@ -516,8 +516,23 @@ async def allapps(request:Request,c:config.KINTONE_ENV=Depends(getkintoneenv)):
try:
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE}
url = f"{c.BASE_URL}{config.API_V1_STR}/apps.json"
r = httpx.get(url,headers=headers)
return r.json()
offset = 0
all_apps = []
while True:
r = httpx.get(f"{url}?limit=100&offset={offset}", headers=headers)
json_data = r.json()
if "apps" in json_data:
all_apps.extend(json_data["apps"])
if len(json_data["apps"]) == 100:
offset += 100
else:
break
else:
break
return {"apps": all_apps}
except Exception as e:
raise APIException('kintone:allapps', request.url._url, f"Error occurred while get allapps({c.DOMAIN_NAME}):", e)