質問編集履歴
1
回答後のコードを追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -35,4 +35,24 @@
|
|
35
35
|
|
36
36
|
"statisticName": s を抜いたばいいうまく結果がでるので 該当箇所はここだと特定できているのですが、
|
37
37
|
ドキュメントのサンプリには該当箇所が 「statisticName=Total+MB」のようになっているので、「%22」
|
38
|
-
を取り除きたいのですが、どのように直したらいいでしょうか。
|
38
|
+
を取り除きたいのですが、どのように直したらいいでしょうか。
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
最終
|
45
|
+
```python
|
46
|
+
def setParameters(s, d=maya.when("1 month ago")):
|
47
|
+
"""set Parameters for make usage call to API."""
|
48
|
+
return {"billingDayOnly": "true", "statisticName": f"{s}","month": d.month, "year": d.year, }
|
49
|
+
|
50
|
+
def getListUsageperContract(contractId, productId, parameters):
|
51
|
+
"""measures{?billingDayOnly,fromMonth,fromYear,month,statisticName,toMonth,toYear,year}"""
|
52
|
+
path = f"/billing-center-api/v2/contracts/{contractId}/products/{productId}/measures"
|
53
|
+
data_string = parse.urlencode(parameters)
|
54
|
+
result = s.get(parse.urljoin(BASEURL, path), params=data_string)
|
55
|
+
return result
|
56
|
+
|
57
|
+
```
|
58
|
+
parse.urlencode を直接読み込むと"billingDayOnly": True =>?billingDayOnly=True になってしまいエラーになったので 文字列 "true" にするとうまくいきました。
|