Closed kaneplusplus closed 9 years ago
Hi @kaneplusplus!
So I'm not exactly sure why the POST data is not going into the request body, but when I tried this out, I noticed that it is showing up in the query arguments to post()
(i.e., in kwargs
). You can insert this line at the top of post()
to verify on your end:
tangelo.log("SARUMAN", kwargs)
You should see a dict
show up in the log with the appropriate text
property, when you execute the curl
command. If you don't, we will have some more digging to do. If you do, and this doesn't solve your problem (because you particularly depend on data being in the request body, rather than being transferred to the query arguments) then we can look further to see how to accomplish that.
Let me know, and thanks for the bug report!
Do I need to use the tangelo.request body? It looks like I can just grab the message from kwargs.
[05/Feb/2015:23:15:49] SARUMAN {'{"text": "this will not work"}': u''}
NO BODY!
[05/Feb/2015:23:15:49] SERVICE Could not execute service /test:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tangelo/server.py", line 419, in invoke_service
result = restfunc(*pargs, **kwargs)
File "/home/azureuser/entity-extractor/test.py", line 14, in post
params = json.loads(request_body)
File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
I think you can skip the request_body
stuff and just grab the data from kwargs
. If this resolves your issue, I will go ahead and close this, though I will make a note to clarify the documentation on this point, and investigate under what circumstances data winds up in the actual body of the request.
Good enough for me. Thanks for your help.
Calling the plugin above with:
returns the following from tagelo: