API to create Document keep failing

30 views
Skip to first unread message

Nguyen Do Le Bao

unread,
Aug 28, 2014, 3:14:03 AM8/28/14
to erpnext-dev...@googlegroups.com
Hi, 

I am using postman to create a document based on API. 
But seem like it keep failing to parse the Request Body. 
How do i make it work ?


Pratik Vyas

unread,
Aug 29, 2014, 2:06:53 AM8/29/14
to erpnext-dev...@googlegroups.com
Hi Nguyen,

Your body is malformed.

I tried to create a Purchase order (in our demo env) using the Postman tool like this,

http://i.imgur.com/tv0fsgT.png

with the data being

{"supplier": "Asiatic Solutions", "po_details":  [{   "doctype": "Purchase Order Item",   "name": "New Purchase Order Item 1",   "stock_uom": "Nos",   "item_code": "Base Bearing Plate",   "item_group": "Raw Material",   "description": "1/4 in. x 6 in. x 6 in. Mild Steel Plate",   "stock_qty": 1,   "base_price_list_rate": 15,   "brand": null,   "barcode": null,   "base_amount": 15,   "expense_account": null,   "projected_qty": null,   "item_tax_rate": "{}",   "rate": 15,   "cost_center": "Main - WP",   "qty": 1,   "price_list_rate": 15,   "pricing_rule": null,   "discount_percentage": 0,   "item_name": "Base Bearing Plate",   "income_account": "Sales - WP",   "min_order_qty": "",   "amount": 15,   "conversion_factor": 1,   "batch_no": null,   "warehouse": "Stores - WP",   "supplier_part_no": null,   "base_rate": 15,   "uom": "Nos",   "received_qty": 0,   "billed_amt": 0,   "schedule_date": "2014-08-23" }] }

Pretty printed:

{
  "supplier": "Asiatic Solutions",
  "po_details": [
    {
      "doctype": "Purchase Order Item",
      "name": "New Purchase Order Item 1",
      "stock_uom": "Nos",
      "item_code": "Base Bearing Plate",
      "item_group": "Raw Material",
      "description": "1/4 in. x 6 in. x 6 in. Mild Steel Plate",
      "stock_qty": 1,
      "base_price_list_rate": 15,
      "brand": null,
      "barcode": null,
      "base_amount": 15,
      "expense_account": null,
      "projected_qty": null,
      "item_tax_rate": "{}",
      "rate": 15,
      "cost_center": "Main - WP",
      "qty": 1,
      "price_list_rate": 15,
      "pricing_rule": null,
      "discount_percentage": 0,
      "item_name": "Base Bearing Plate",
      "income_account": "Sales - WP",
      "min_order_qty": "",
      "amount": 15,
      "conversion_factor": 1,
      "batch_no": null,
      "warehouse": "Stores - WP",
      "supplier_part_no": null,
      "base_rate": 15,
      "uom": "Nos",
      "received_qty": 0,
      "billed_amt": 0,
      "schedule_date": "2014-08-23"
    }
  ]
}

It did work.
Will strengthen the API to give meaningful Validation errors



--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/4fc36d2d-788e-4fe6-8a25-c5c146eb4435%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Pratik
erpnext
Reply all
Reply to author
Forward
0 new messages