Trouble updating an Item via Rest Api

Hi all. I am attempting to integrate ERPNext with another system and although I can login and get the item, when I submit an update via PUT, I receive a status of 200 OK along with the body of the item as it was before. So the update failed, yet I get a status of 200 OK. Is this expected?

For this test I am using POSTMAN.
Login works => {
“home_page”: “/desk”,
“message”: “Logged In”,
“full_name”: “Administrator”
}
Then I test ability to get the item
https://xxx.com/api/resource/Item?fields=[“name”, “item_name”,“description”, “salesdescription”, “web_long_description”]&filters=[[“Item”, “item_name”, “=”, “CDAH005”]]
=> STATUS 200 OK
{
“data”: [
{
“item_name”: “CDAH005”,
“web_long_description”: null,
“name”: “CDAH005”,
“salesdescription”: “Owl - Gourd Ornament, assorted designs”,
“description”: “Buho (Viejo + Joven) Ornamento Mate 2’’ - 2.5’'H”
}
]
}
So then I PUT to https://xxx.com/api/resource/Item/CDAH005
with header Content-Type application/json
and Body (raw with JSON(application/json) selected)
{“data”:{“web_long_description”:“This is a test.”,“description”:“TEST Buho (Viejo + Joven) Ornamento Mate”,“salesdescription”:“TEST Owl - Gourd Ornament, assorted designs”}}

Yet I get back RESPONSE 200 OK with body (shortened a bit) =
{“data”:{“website_specifications”:[],“default_supplier”:null,“selling_cost_center”:“Main - APU”,“net_weight”:0.027,“disabled”:0,“modified”:“2017-03-11 09:33:20.229390”,“size_label”:null,“reorder_levels”:[],“modified_by”:“Administrator”,“income_account”:“70120 Ventas - Otros - APU”,“item_name”:“CDAH005”,“technique”:null,“will_be_inactivated”:null,“website_warehouse”:null,“theme”:null,“default_material_request_type”:“Purchase”,“categoria”:null,“website_item_groups”:[],“salesdescription”:“Owl - Gourd Ornament, assorted designs”,“max_discount”:0.0,“name”:“CDAH005”,“item_group”:“Products”,“taxes”:[],“web_long_description”:null,“parentfield”:null,“creation”:“2014-07-18 17:22:50.360946”,“factura”:“Ornamento de mate naturaleza A”,“variant_of”:null,“hts”:“H.T.S. 0604.99.3000”,“has_variants”:0,“supplier_items”:[],“inspection_required_before_delivery”:0,“is_sales_item”:1,“is_sub_contracted_item”:0,“tolerance”:50.0,“thumbnail”:“/files/PCDAH005_small.jpg”,“customer_code”:“”,“parent”:null,“barcode”:null,“quality_parameters”:[],“is_stock_item”:1,“customer_items”:[],“size”:null,“tomano”:null,“valuation_method”:“FIFO”,“slideshow”:null,“item_code”:“CDAH005”,“uoms”:[{“modified_by”:“Administrator”,“name”:“UCDD/00063”,“parent”:“CDAH005”,“creation”:“2014-07-18 17:22:50.360946”,“modified”:“2017-03-11 09:33:20.229390”,“doctype”:“UOM Conversion Detail",“idx”:1,“parenttype”:“Item”,“conversion_factor”:1.0,“owner”:"don@lucuma.com”,“docstatus”:0,“uom”:“Unit”,“parentfield”:“uoms”}],“last_purchase_rate”:3.0,“naming_series”:“ITEM-”,“item_material”:null,“publish_in_hub”:0,“parenttype”:null,“serial_no_series”:null,“end_of_life”:“2099-12-31”,“synced_with_hub”:0,“stock_uom”:“Unit”,“show_variant_in_website”:0,“docstatus”:0,“description”:“Buho (Viejo + Joven) Ornamento Mate 2’’ - 2.5’'H”,“asset_category”:null,“default_bom”:null,“weightage”:0,“total_projected_qty”:500.0,“lead_time_days”:0,“opening_stock”:0.0,“has_batch_no”:0,“has_serial_no”:0,“standard_rate”:0.0,“is_fixed_asset”:0,“inspection_required_before_purchase”:0}}

So it updates the modification time, but doesn’t change the fields or throw an error that I can tell. Ideas? Thank you!

try using:

data:{"web_long_description":"This is a test.","description":"TEST Buho (Viejo + Joven) Ornamento Mate","salesdescription":"TEST Owl - Gourd Ornament, assorted designs"}

instead of

{data:{"web_long_description":"This is a test.","description":"TEST Buho (Viejo + Joven) Ornamento Mate","salesdescription":"TEST Owl - Gourd Ornament, assorted designs"}}

https://frappe.github.io/frappe/user/en/guides/integration/rest_api.html

Updating ToDo seems to work well on my server.

Hi and thanks for the idea and the photo that explained it!

So after login and confirm that item exists via GET https://xxx.com/api/resource/Item/CDAH005

I tried:
PUT to https://xxx.com/api/resource/Item/CDAH005
with Body set to “Raw” and Content-Type = application/json
with following body variations

  1. Result 500 Internal Error
    data:{“web_long_description”:“test.”,“description”:“TEST Buho”,“salesdescription”:“TEST Owl”}

  2. Result 500 Internal Error
    “data”:{“web_long_description”:“test.”,“description”:“TEST Buho”,“salesdescription”:“TEST Owl”}

  3. Exactly as help suggests for person … data={“last_name”: “Watson”}
    Result 500 Internal Error
    data={“web_long_description”:“test.”,“description”:“TEST Buho”,“salesdescription”:“TEST Owl”}

Then I noticed you used x-www-form-urlencoded, so switching to
PUT to https://xxx.com/api/resource/Item/CDAH005
with Body set to “x-www-form-urlencoded” and Content-Type = application/x-www-form-urlencoded

  1. Success! It actually updated.
    data:{“web_long_description”:“test.”,“description”:“TEST Buho”,“salesdescription”:“TEST Owl”}

Result: {
“data”: {
“salesdescription”: “TEST Owl”,
“web_long_description”: “test.”, …

Note, the help version with above settings
data={“web_long_description”:“test2.”,“description”:“TEST Buho2”,“salesdescription”:“TEST Owl”}
=> 500 Internal Server Error

1 Like