Hello,

I'm using filed Collection module to arrange fields in my site..

field Collection has working entity property integration...

but i can't get the Json file

if i go to http://localhost/testingservices/field-collection/field-orders/1.json i will get the first value of the field collection in an html view and not in JSON format

Appreciate your help

Comments

Wassim Ghannoum’s picture

i Think it is working now:

using this format, http://localhost/testingservices/field_collection_item/3.json

but how can i create a new item of field_collection using this module ? ?

sepgil’s picture

You have to use the HTTP Put Method and I think also set the Content-Type header to an appropriate format(like application/json) to create a new entity.

Wassim Ghannoum’s picture

I'm using java script

and i used this code:

		var filed_collection = {
			field_food_reference:{
				id: 1,
				resource:'node'
			},
			field_line_options: 
			  [
			    'Bala Toum','Bala Banadoura','Markouk'
			  ]
			,
			field_name:'field_orders',
			field_order_line_price:'3',
			field_quantity:'1'
		 };

		// Define the url 
		// in this case, we'll connecting to http://example.com/api/rest/node
		var url = SITE_PATH + 'field_collection_item';
		
		// Use $.ajax to create the node
		$.ajax({
	        type: "PUT",
	        url: url,
	        data: JSON.stringify(filed_collection), // Stringify the node
	        dataType: 'json',
	        contentType: 'application/json',
	        // On success do some processing like closing the window and show an alert
	        success: function(data) {
	            alert("Content created with id " + data.nid);
	            win.close();
	        },
	    });

in the log file of the module i'm getting:

2012-05-31T09:08:49+0300
Resource: field_collection_item
Operation: create
Format: application/json
Id:
Payload: {"field_food_reference":{"id":1,"resource":"node"},"field_line_options":["Bala Toum","Bala Banadoura","Markouk"],"field_name":"field_orders","field_order_line_price":"3","field_quantity":"1","host_entity":{"id":4,"resource":"node"},"item_id":4}

But nothing has been created!

i tried to add an item manually from the website and this was the result:

{"field_food_reference":{"uri":"http:\u002F\u002Flocalhost\u002Fdrupanium\u002Fnode\u002F1", "id":"1", "resource":"node"}, "field_quantity":"10", "field_order_line_price":"30", "field_line_options":[ ], "item_id":"3", "field_name":"field_orders", "url":"http:\u002F\u002Flocalhost\u002Fdrupanium\u002Ffield-collection\u002Ffield-orders\u002F3", "host_entity":{"uri":"http:\u002F\u002Flocalhost\u002Fdrupanium\u002Fnode\u002F3", "id":"3", "resource":"node"}}

Wassim Ghannoum’s picture

I'm using java script

and i used this code:

		var filed_collection = {
			field_food_reference:{
				id: 1,
				resource:'node'
			},
			field_line_options: 
			  [
			    'Bala Toum','Bala Banadoura','Markouk'
			  ]
			,
			field_name:'field_orders',
			field_order_line_price:'3',
			field_quantity:'1'
		 };

		// Define the url 
		// in this case, we'll connecting to http://example.com/api/rest/node
		var url = SITE_PATH + 'field_collection_item';
		
		// Use $.ajax to create the node
		$.ajax({
	        type: "PUT",
	        url: url,
	        data: JSON.stringify(filed_collection), // Stringify the node
	        dataType: 'json',
	        contentType: 'application/json',
	        // On success do some processing like closing the window and show an alert
	        success: function(data) {
	            alert("Content created with id " + data.nid);
	            win.close();
	        },
	    });

in the log file of the module i'm getting:

2012-05-31T09:08:49+0300
Resource: field_collection_item
Operation: create
Format: application/json
Id:
Payload: {"field_food_reference":{"id":1,"resource":"node"},"field_line_options":["Bala Toum","Bala Banadoura","Markouk"],"field_name":"field_orders","field_order_line_price":"3","field_quantity":"1","host_entity":{"id":4,"resource":"node"},"item_id":4}

But nothing has been created!

i tried to add an item manually from the website and this was the result:

{"field_food_reference":{"uri":"http:\u002F\u002Flocalhost\u002Fdrupanium\u002Fnode\u002F1", "id":"1", "resource":"node"}, "field_quantity":"10", "field_order_line_price":"30", "field_line_options":[ ], "item_id":"3", "field_name":"field_orders", "url":"http:\u002F\u002Flocalhost\u002Fdrupanium\u002Ffield-collection\u002Ffield-orders\u002F3", "host_entity":{"uri":"http:\u002F\u002Flocalhost\u002Fdrupanium\u002Fnode\u002F3", "id":"3", "resource":"node"}}

ntigh52’s picture

Issue summary: View changes

Hi All,
You are right!!
When I have entity reference field so on the jsom I can get just the entity-id ( not the title as it display on the node).
But, in the field collection module, the field_collection_item id is only shown.
Is there not a way to send all the information of the fields collection with the json?
Important to mention that on the $node variable inside the field collection field I have all the information.
Thanks a lot.

ntigh52’s picture

Version: 7.x-1.0-beta2 » 7.x-2.2
roppa_uk’s picture

I'm having the same problem. I've created a custom module that we use in a field collection. The data is there, but it is not being exposed using RESTws. I tested if the data was there in a hook, and the fields are there. It is like fields are being filtered by the time RESTws is finished processing. Any ideas?