Simple use of Services with JSON
I am trying a simple test with Drupal 6, Services, JSON Server but am running into the following error. To make things as simple as possible, I tried this with the curl command line program (although I have also tried it in python and php). I have services and json server installed and can go to services at mysite.com/admin/build/services/browse/service.name and successfully browse a view I made using views.get. I also did this with node.get However (all on the same machine) when I try:
curl --data method=views.get --data view_name="myview" http://mysite/services/json
or
curl --data method=system.getServices http://mysite/services/?q=services/json
or
curl --data method=system.connect http://mysite/services/?q=services/json
etc...
I always get:
{ "#error": true, "#data": "Invalid method " }
although I see that is it using a service called echo.
Can anyone help with this?
Thanks very much

Any luck with this?
Any luck with this?
Works for me
I tested out the last two examples against my server and they worked fine.
Output from last one since it's short.
curl --data method=system.connect http://{mysite}/services/?q=services/json
{ "#error": false, "#data": { "sessid": "45572a32241703b5c7fd0f03d1d8466f", "user": { "uid": 0, "hostname": "{ip removed}", "roles": { "1": "anonymous user" }, "session": "", "cache": 0 } } }j
do you still have trouble?
I would leave out the first services ie:
http://{mysite}/?q=services/json
I still have troubles
I always get: { "#error": true, "#data": "Invalid method " } in any cases.
http://{mysite}/?q=services/json
http://{mysite}/services/?q=services/json
http://{mysite}/services/json
http://{mysite}/services/services/json
none of the methods work.
any suggestions?
Sorted it...
vmtest6 is the name of one of dev sites. The key seems to be to wrap system.connect in quotes to make the json decode function treat it as a json string.
[nthompson@localhost ~]$ curl --data 'method="system.connect"' http://vmtest6/services/json{ "#error": false, "#data": { "sessid": "01add0fjfgrql7ntf4p1211p94", "user": { "uid": 0, "hostname": "192.168.216.128", "roles": { "1": "anonymous user" }, "session": "", "cache": 0 } } }
same problem.. I always get {
same problem..
I always get { "#error": true, "#data": "Invalid method " }