JSON request to form for creating a node

darkdim's picture

Please help to properly create Jason request to send a form to create a node

I get an error:

"form_errors": {
    "field_product][und][form][sku": "SKU field is required.",
    "field_product][und][form][commerce_price][und][0][amount": "Discount Price field is required.",
    "field_product][und][form][commerce_sales][und][0][value": "Sales field is required.",
    "field_timending][und][0][value": "A valid date is required for <em class=\"placeholder\">Valid Until</em>."

what am i doing wrong?

the query such

{"type": "deal","title": "Some title",
"field_product":{"und":[{"form":{"commerce_sales":{"und":[{"0":{"value": "10"}}]}}}]},
"field_city": {"und":"Agra"},
"field_deal_address":{"und":[{"thoroughfare": "Ratan Muni Rd, Kailashpuri"}]},
"field_deal_address":{"und":[{"locality":"Agra" }]}


Hi. Did you found the

briantes's picture

Hi. Did you found the mistake? I have the same question. I can create product (variant types as I see) but I can't create products nodes due the same error.


briantes's picture

I've found the error. Firstable, my drupal commerce installation hasn't product_display content type. I have to add it manually. I don't know why, but It's missing after clean installation. Secondly, the right JSON structure for commerce price section is:

"field_product":{ "und" :
{ "form": {
"commerce_price": {
"und": [ {
"amount": "1234.34",
"currency_code": "EUR",
"data": { "components": [] }
} ]
After this change, I can create products display and I can see it on product manage page.

And you have to set node type to "product_display".


darkdim's picture

{ "type":"deal",
"title":"your title",
"field_timending":{"und":[{"value":{"date":"2015-07-12","time": "11:14"}}]},


"field_deal_address":{"und":[{"country":"IN","locality":"Agra","thoroughfare": "Ratan Muni Rd, Kailashpuri", "administrative_area":"Uttar Pradesh", "postal_code":"282006"}]},

"field_product":{"und": {"form":{"commerce_price":{"und": [{ "amount": "100","currency_code": "INR"}]},

"field_or_price":{"und": [{ "amount": "200","currency_code": "INR"}]},


"field_stock":{"und": [{ "amount": "1000"}]},

"field_details":{"und":[{ "value": "Some Description","format":"filtered_html"}]}