質問編集履歴

1

回答後のコードを追加

2017/10/20 02:40

投稿

Kentaro0919
Kentaro0919

スコア258

test CHANGED
File without changes
test CHANGED
@@ -73,3 +73,43 @@
73
73
  ドキュメントのサンプリには該当箇所が 「statisticName=Total+MB」のようになっているので、「%22」
74
74
 
75
75
  を取り除きたいのですが、どのように直したらいいでしょうか。
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+ 最終
88
+
89
+ ```python
90
+
91
+ def setParameters(s, d=maya.when("1 month ago")):
92
+
93
+ """set Parameters for make usage call to API."""
94
+
95
+ return {"billingDayOnly": "true", "statisticName": f"{s}","month": d.month, "year": d.year, }
96
+
97
+
98
+
99
+ def getListUsageperContract(contractId, productId, parameters):
100
+
101
+ """measures{?billingDayOnly,fromMonth,fromYear,month,statisticName,toMonth,toYear,year}"""
102
+
103
+ path = f"/billing-center-api/v2/contracts/{contractId}/products/{productId}/measures"
104
+
105
+ data_string = parse.urlencode(parameters)
106
+
107
+ result = s.get(parse.urljoin(BASEURL, path), params=data_string)
108
+
109
+ return result
110
+
111
+
112
+
113
+ ```
114
+
115
+ parse.urlencode を直接読み込むと"billingDayOnly": True =>?billingDayOnly=True になってしまいエラーになったので 文字列 "true" にするとうまくいきました。