Set parameters in the observation request
Closed this issue · 5 comments
I sent the following request to whoami resource located in server.py.
request = Message(code=GET, uri='coap://localhost:13928/whoami?param=32')
Then I tried to display the param value inside in the render_get method of whoami resource.
text = ["*****************: %s.*******************" % request.payload]
I get a an empty request parameters.
How I can send observation parameters to the resource in order to create certain login there ?
Thanks @chrysn for the support.
I keep the same file server.py as as it is in the repo with exception of modifying whoami resource:
async def render_get(self, request):
text = ["*****************: %s.*******************" % request.payload]
set the observe option
You mean ?
request.opt.observe = 0
request.opt.observe = 0
yes, or simply
request = Message(code=GET, uri='coap://localhost:13928/whoami?param=32', observe=0)
async def render_get(self, request):
text = ["*****************: %s.*******************" % request.payload]
Why should that show the query parameter? All you access is the payload.
Ah sorry @chrysn, I thought I am working with PUT or FETCH methods.
So how I can show the query parameter in the GET request?
The query parameter of CoAP is transported in the Uri-Query option. You can access it directly through request.opt.uri_query
(in its "natural" form), or in composite URI form through the request.get_request_uri()
getter.