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 " }

http://drupal.org/node/239806

although I see that is it using a service called echo.

Can anyone help with this?

Thanks very much

Groups:
Login to post comments

Any luck with this?

ninjay's picture
ninjay - Fri, 2009-07-17 23:09

Any luck with this?


Works for me

wendelj - Wed, 2009-09-30 04:34

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?

pbharrin - Tue, 2009-10-06 19:48

I would leave out the first services ie:
http://{mysite}/?q=services/json


I still have troubles

wira.perdana - Tue, 2009-10-13 00:49

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...

nicholasThompson's picture
nicholasThompson - Sun, 2009-11-01 22:54

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 {

upupax - Wed, 2009-11-04 17:58

same problem..
I always get { "#error": true, "#data": "Invalid method " }