I had to remove the underscore in the method name too. from: save_message() to: savemessage()
#!/bin/bash message=$1 uid=$2 url="https://host.com/ircmessage/rpc/call/jsonrpc" curl -v -k -X POST -H "Content-Type: application/json" -d "{\"id\": 1, \"method\": \"savemessage\", \"params\": { \"${message}\": \"mymessage\", \"${uid}\" : \"myemail@localhost\"}}" $url There is slightly strange behavior in that the value of the parameter name is what is saved instead of the value. So the value of ${message} is saved rather than "mymessage" Many thanks for your time Nyphlod. On Wednesday, 7 November 2012 16:03:08 UTC-5, Niphlod wrote: > > supposedly you have call() and save_message() in default.py > > The url to call the webservice would then be /appname/default/call/jsonrpc > . > > On Wednesday, November 7, 2012 9:31:51 PM UTC+1, Mike Anson wrote: >> >> Thanks very much Niphlod. I am much closer now.. >> >> However I am getting this response: >> {"version": "1.1", "id": 1, "error": {"message": "method >> \"save_message\" does not exist", "code": 100, "name": "JSONRPCError"}} >> >> from this script: >> url="https://domain.net:8000/ircmessage/rpc/call/jsonrpc" >> curl -v -k -X POST -H "Content-Type: application/json" -d '{"id": 1, >> "method": "save_message", "params": { "message": "mymessage", "uid" : >> "myemail@localhost"}}' $url >> >> I guess my url is probably incorrect. >> >> Cheers again Niphlod. >> >> On Wednesday, 7 November 2012 15:16:42 UTC-5, Niphlod wrote: >>> >>> Yes, but without that I wouldn't have been able to tell you: "Follow the >>> protocol, Mike!" :P >>> >>> You are publishing a service behind the jsonrpc protocol, but you surely >>> missed on how to interact with them ^_^ >>> >>> Every request per the spec has to carry an id , a method and a params >>> value in the json body of the request. >>> >>> So, you are trying to fire function that needs 'message' and 'uid' >>> parameters, and the function is called 'save_message' >>> The following json must be POSTed (and using single quotes will save you >>> lots of backslashes if you're using cURL) >>> >>> '{"id": 1, "method": "save_message", "params": { "message": "mymessage", >>> "uid" : "myemail@localhost"}}' >>> >>> So, the complete cmdline is >>> curl -v -k -X POST -H "Content-Type: application/json" -d '{"id": 1, >>> "method": "save_message", "params": { "message": "mymessage", "uid" : >>> "myemail@localhost"}}' $url >>> >>> This will generate a response like this >>> {"error": null, "version": "1.1", "id": 1, "result": {"status": "saved"}} >>> >>> The 'id' is the one you sent (so, if you POST id=2, the response will >>> hold 2, and so on). In "result" you get what you return in the controller. >>> >>> >>> --