質問編集履歴

5

追記

2019/12/11 16:48

投稿

yep.app
yep.app

スコア11

test CHANGED
File without changes
test CHANGED
@@ -39,6 +39,10 @@
39
39
  b'{"error_code":15,"error":"処理名が無効です。","error_description":"パラメータ不正です。(procName is empty)"}'
40
40
 
41
41
 
42
+
43
+ #urlエンコードする前
44
+
45
+ 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
42
46
 
43
47
  #paramsをurlエンコードした結果
44
48
 

4

ソースをシンプルにしました

2019/12/11 16:48

投稿

yep.app
yep.app

スコア11

test CHANGED
File without changes
test CHANGED
@@ -38,6 +38,14 @@
38
38
 
39
39
  b'{"error_code":15,"error":"処理名が無効です。","error_description":"パラメータ不正です。(procName is empty)"}'
40
40
 
41
+
42
+
43
+ #paramsをurlエンコードした結果
44
+
45
+ #print(r.url)
46
+
47
+ 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
48
+
41
49
  ```
42
50
 
43
51
 
@@ -74,7 +82,7 @@
74
82
 
75
83
  #paramsを定義
76
84
 
77
- form = customer_ref, *params = {
85
+ params = {
78
86
 
79
87
  "proc_Name":"customer_ref",
80
88
 
@@ -94,7 +102,7 @@
94
102
 
95
103
  #json分解不可を回避
96
104
 
97
- form = urllib.parse.quote(str(params))
105
+ params = urllib.parse.quote(str(params))
98
106
 
99
107
 
100
108
 
@@ -114,7 +122,7 @@
114
122
 
115
123
  #リクエストをPOST
116
124
 
117
- r = requests.post(url=url, params=form, headers=headers, auth=(user_name, password))
125
+ r = requests.post(url=url, params=params, headers=headers, auth=(user_name, password))
118
126
 
119
127
 
120
128
 
@@ -123,6 +131,8 @@
123
131
  print(r.reason)
124
132
 
125
133
  print(r.content)
134
+
135
+ print(r.url)
126
136
 
127
137
  ```
128
138
 

3

追記

2019/12/10 18:36

投稿

yep.app
yep.app

スコア11

test CHANGED
File without changes
test CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
 
44
44
 
45
- ### 該当のソースコード
45
+ ## 該当のソースコード
46
46
 
47
47
 
48
48
 
@@ -128,6 +128,10 @@
128
128
 
129
129
 
130
130
 
131
+ ### 参考文献
132
+
133
+ [「スマレジ APIのご紹介」](https://docs.google.com/presentation/d/11o32-Co6ZFG8rEvu47fie-YbWB83M7g-kZcxLdo10AY/edit?usp=sharing)のスライド
134
+
131
135
 
132
136
 
133
137
  ### 補足情報(FW/ツールのバージョンなど)

2

文法の改善

2019/12/10 18:09

投稿

yep.app
yep.app

スコア11

test CHANGED
File without changes
test CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  - [https://smaregi.jp/](https://smaregi.jp/)で自分のアカウントを作成し、実験しています。
18
18
 
19
- - ソースで、`json`で`proc_Name`を指定していますが、無効になってしまいます。
19
+ - ソースで、`proc_Name`を指定していますが、エラーメッセージに影響は見られたです。
20
20
 
21
21
  - プロセス名を指定したいため、`requests`のドキュメントにある`proc_name --name customer_ref`とオプションをつけても結果は変わりませんでした。
22
22
 

1

タイトルの詳細化

2019/12/10 17:42

投稿

yep.app
yep.app

スコア11

test CHANGED
@@ -1 +1 @@
1
- スマレジAPIで不正パラメーターとなってまう
1
+ requestsを使い、スマレジAPIで顧客データを参照たい
test CHANGED
File without changes