Closed (fixed)
Project:
JSON server
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
1 Jul 2011 at 12:09 UTC
Updated:
14 Dec 2011 at 16:13 UTC
I don't get it: the project page for json_server states it won't be necessary for services 3.x because it has json built-in.
I've setup services 3.0-rc1 and am unable to create a JSON server. When I look in the code I don't see a json server anywhere either. Is the information on the project page perhaps outdated? Am I overlooking something?
Comments
Comment #1
welly commentedIf you set up a service in Services 3 - a REST service and set your end point (say api) - if you do http://example.com/api/node/1.json - it'll give you json content for node 1 or http://example.com/api/node.json will give you json content for a bunch of nodes. That's all I have figured out so far :)
Comment #2
spazefish commentedDrupal 7 services 3 json , I put that there so people can find it with google easier.
I am having the same issues, with the REST thing. It is very unclear how the json thing works, does it let me create an object in JSON and send it to my api/service endpoint and it recieves it and interprets it similar as to how json server does it?
I don't think so, at least I can't get it to work yet, it's not like the json server, but oddly enough on the project page for json server it says json server will not be developed for drupal 7 because services 3 support json out of the box, which is semi-true I suppose? I mean you can perhaps retrieve with json, but if you develop web app with javascript it would be extremely useful to be able to send json as well, for consuming these webservices. Right now, I don't think you can.... please prove me wrong though! Cause this is exactly what I want ;-)
Afaik there are no examples at all in the services 3 manual for this, or how it works with json... :/
Comment #3
askibinski commentedYeah, I reverted back to services 2.x with json_server for the time being. Looking at the comment in #1 json might be a very well undocumented feature of services 3?
Comment #4
spazefish commentedFound out how todo this for drupal 7 with Services 3, the answer is yes the REST server does accept json both for sending and receiving.
It's just the Services documentation is awful, completely hopeless, I have been taking shots in the dark to get this working, still can't get comments working, but on the way there.
Ok so to make this work create your endpoint, lets say its http://yourdrupalsite/myendpoint
Now to create a new node with javascript you will do something like: (Provided you have activated the node resource etc)
So yes the object in javascript needs to have that exact structure, then you make the post with ajax... if you use jquery like so:
And obviously it's similar with the other resources, however comments I cant get working, I make the object like so:
However the response I get is " 406 (Not Acceptable: Comment field is required.) "
The comment JSON is semi correct because if I change the structure it complains about missing argument comment, here it just complains about a missing field, which I dont really know what it is I suppose it might be called differently the "body" of the comment perhaps.
Now to consume the comment resource
Anwyay at last some progress
Comment #5
spazefish commentedGot the commenting working as well, the comment object if you pass it from javascript needs to look like this:
Then pass it with the same ajax used above, obviously nid is the node id. Now looking for something to retrieve X comments from a node + some other useful things.
Comment #6
skyredwangComment #7
lelizondo commentedI read #4 but is not working for me using Services 3.0
The response is 406.
However,
Works, the node is saved, BUT, the body is not saved, only the title.
Can someone please help me out with this please?
Comment #8
skyredwangjson_server only works with Services 2.x
Comment #9
lelizondo commentedSorry about that, I didn't see what the project was, I thought it was Services.
Comment #10
boran commentedSorry to post to a closed issue, but, as I understand it,
the services 3.x json/rest interface only allows CRUD operations, it does not allows custom remote functions e.g. calling service.foo($object) .
Has anyone a suggestion to replace this functionality for D7?