Hi all
I have a HTTP endpoint defined like this:
@anvil.server.http_endpoint("/servercallback")
def server_callback(**params):
print('QUERYSTRING PARAMS')
print(params)
form_params = anvil.server.request.form_params
print('FORM PARAMS')
print(form_params)
body = anvil.server.request.body
print('REQ BODY')
print(body)
json = anvil.server.request.body_json
print('REQ BODY JSON')
print(json)
print('ALL REQUEST PROPERTIES:')
print('Headers')
print(anvil.server.request.headers)
print('Method')
print(anvil.server.request.method)
print('Origin')
print(anvil.server.request.origin)
print('Password')
print(anvil.server.request.password)
print('Path')
print(anvil.server.request.path)
print('Query Params')
print(anvil.server.request.query_params)
print('Remote Address')
print(anvil.server.request.remote_address)
print('Username')
print(anvil.server.request.username)
This way I log everything to my APP log for testing purposes.
I call this with POSTMAN method POST and pass parameters (testing purposes) both as querystring and form_data:
What I get in the APP Log is:
QUERYSTRING PARAMS
{'query_param': 'querystring'}
FORM PARAMS
{}
REQ BODY
<anvil._serialise.StreamingMedia object at 0x0000000001a3c918>
REQ BODY JSON
None
ALL REQUEST PROPERTIES:
Headers
{'host': 'platform-server:3000', 'user-agent': 'PostmanRuntime/7.24.1', 'content-type': 'multipart/form-data; boundary=--------------------------315042450429081305573792', 'cookie': None, 'content-length': '174', 'accept': '*/*', 'ssl-client-verify': 'NONE', 'x-forwarded-for': '79.19.65.234', 'accept-encoding': 'gzip, deflate, br', 'postman-token': 'ab247f0b-deb0-44bb-9cc6-446a7bc47675', 'x-real-ip': '79.19.65.234', 'cache-control': 'no-cache', 'anvil-host': 'ry2cnmkusvykd3fw.anvil.app'}
Method
POST
Origin
None
Password
None
Path
/servercallback
Query Params
{'query_param': 'querystring'}
Remote Address
79.19.65.234
Username
None
Why can’t I see body_param
and its value?
I need to read formdata because my endpoint is called by an external application that passes data that way, using POST method.
I feel I’m missing something simple, but I’ve searched the forum and the docs and can’t really find a clue.
Thanks and BR