ここではPythonスクリプトを使用してログイン保護されたAPIに接続しています。requests.post with Python
import requests
url = 'https://api.json'
header = {'Content-Type': 'application/x-www-form-urlencoded'}
login = ('[email protected]', 'xxxxx')
mnem = 'inputRequests':'{'inputRequests':'[{'function':'GDSP','identifier':'ibm','mnemonic':'IQ_TOTAL_REV'}]}}
r = requests.post(url, auth=login, data=mnem, headers=header)
print(r.json())
接続が確立されましたが、データリクエストの形式のためにAPIからエラーが発生しています。元の形式は以下のとおりです。指定したエラーが、私はここから続行する方法についてわからないよ
C:\Users\xxx\Desktop>pie.py
File "C:\Users\xxx\Desktop\pie.py", line 6
mnem={'inputRequests':'{'inputRequests':'[{'function':'xxx','identifier':'xx','mnemonic':'xxx'}]}}
^
SyntaxError: invalid syntax
ある
inputRequests={inputRequests:
[
{function:"xxx",identifier:"xxx",mnemonic:"xxx"},
]
}
:私は上記のここMNEMでこれを入力する方法を見つけることができません。要求のドキュメントで、データフィールドに複数の変数を挿入する方法を指摘するものは何も見つかりません。
それは最新の試みの一つであった申し訳ありませんが。したがって、3つのパラメータを渡すための
を使用してみてください。私は以下のようにすべてを閉じ込めましたが、これはまだ動作しません:mnem = {'inputRequests':{'inputRequests':[{'function': 'GDSP'、 'identifier': 'ibm'、 'mnemonic': ' IQ_TOTAL_REV '}]}} –
取得しているエラーメッセージは何かを含めてください。 – iled