質問編集履歴
5
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
#上記の翻訳
|
20
20
|
b'{"error_code":15,"error":"処理名が無効です。","error_description":"パラメータ不正です。(procName is empty)"}'
|
21
21
|
|
22
|
+
#urlエンコードする前
|
23
|
+
http://webapi.smaregi.jp/access/?proc_Name=customer_ref&fields=customerCode&fields=lastName&fields=firstName&conditions=customerId&order=customerCode+desc&limit=100&table_name=Customer
|
22
24
|
#paramsをurlエンコードした結果
|
23
25
|
#print(r.url)
|
24
26
|
http://webapi.smaregi.jp/access/?%7B%27proc_Name%27%3A%20%27customer_ref%27%2C%20%27fields%27%3A%20%5B%27customerCode%27%2C%20%27lastName%27%2C%20%27firstName%27%5D%2C%20%27conditions%27%3A%20%5B%7B%27customerId%27%3A%20%27213%27%7D%5D%2C%20%27order%27%3A%20%5B%27customerCode%20desc%27%5D%2C%20%27limit%27%3A%20100%2C%20%27table_name%27%3A%20%27Customer%27%7D
|
4
ソースをシンプルにしました
title
CHANGED
File without changes
|
body
CHANGED
@@ -18,6 +18,10 @@
|
|
18
18
|
b'{"error_code":15,"error":"\u51e6\u7406\u540d\u304c\u7121\u52b9\u3067\u3059\u3002","error_description":"\u30d1\u30e9\u30e1\u30fc\u30bf\u4e0d\u6b63\u3067\u3059\u3002(procName is empty)"}'
|
19
19
|
#上記の翻訳
|
20
20
|
b'{"error_code":15,"error":"処理名が無効です。","error_description":"パラメータ不正です。(procName is empty)"}'
|
21
|
+
|
22
|
+
#paramsをurlエンコードした結果
|
23
|
+
#print(r.url)
|
24
|
+
http://webapi.smaregi.jp/access/?%7B%27proc_Name%27%3A%20%27customer_ref%27%2C%20%27fields%27%3A%20%5B%27customerCode%27%2C%20%27lastName%27%2C%20%27firstName%27%5D%2C%20%27conditions%27%3A%20%5B%7B%27customerId%27%3A%20%27213%27%7D%5D%2C%20%27order%27%3A%20%5B%27customerCode%20desc%27%5D%2C%20%27limit%27%3A%20100%2C%20%27table_name%27%3A%20%27Customer%27%7D
|
21
25
|
```
|
22
26
|
|
23
27
|
## 該当のソースコード
|
@@ -36,7 +40,7 @@
|
|
36
40
|
url = "http://webapi.smaregi.jp/access/"
|
37
41
|
|
38
42
|
#paramsを定義
|
39
|
-
|
43
|
+
params = {
|
40
44
|
"proc_Name":"customer_ref",
|
41
45
|
"fields":["customerCode","lastName","firstName"],
|
42
46
|
"conditions":[{"customerId":"213"}],
|
@@ -46,7 +50,7 @@
|
|
46
50
|
}
|
47
51
|
|
48
52
|
#json分解不可を回避
|
49
|
-
|
53
|
+
params = urllib.parse.quote(str(params))
|
50
54
|
|
51
55
|
#headerを定義
|
52
56
|
headers = {
|
@@ -56,11 +60,12 @@
|
|
56
60
|
}
|
57
61
|
|
58
62
|
#リクエストをPOST
|
59
|
-
r = requests.post(url=url, params=
|
63
|
+
r = requests.post(url=url, params=params, headers=headers, auth=(user_name, password))
|
60
64
|
|
61
65
|
#結果を表示
|
62
66
|
print(r.reason)
|
63
67
|
print(r.content)
|
68
|
+
print(r.url)
|
64
69
|
```
|
65
70
|
|
66
71
|
### 参考文献
|
3
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
b'{"error_code":15,"error":"処理名が無効です。","error_description":"パラメータ不正です。(procName is empty)"}'
|
21
21
|
```
|
22
22
|
|
23
|
-
##
|
23
|
+
## 該当のソースコード
|
24
24
|
|
25
25
|
```python
|
26
26
|
#coding: utf-8
|
@@ -63,6 +63,8 @@
|
|
63
63
|
print(r.content)
|
64
64
|
```
|
65
65
|
|
66
|
+
### 参考文献
|
67
|
+
[「スマレジ APIのご紹介」](https://docs.google.com/presentation/d/11o32-Co6ZFG8rEvu47fie-YbWB83M7g-kZcxLdo10AY/edit?usp=sharing)のスライド
|
66
68
|
|
67
69
|
### 補足情報(FW/ツールのバージョンなど)
|
68
70
|
Mac OS X
|
2
文法の改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
#### 試した事
|
9
9
|
- [https://smaregi.jp/](https://smaregi.jp/)で自分のアカウントを作成し、実験しています。
|
10
|
-
- ソースで
|
10
|
+
- ソースで、`proc_Name`を指定していますが、特にエラーメッセージに影響は見られなかったです。
|
11
11
|
- プロセス名を指定したいため、`requests`のドキュメントにある`proc_name --name customer_ref`とオプションをつけても結果は変わりませんでした。
|
12
12
|
#### エラーメッセージ
|
13
13
|
```python
|
1
タイトルの詳細化
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
スマレジAPIで
|
1
|
+
requestsを使い、スマレジAPIで顧客データを参照したい
|
body
CHANGED
File without changes
|