Try ERPNext Buy Support Partners Foundation

Error while update field value

Steps

  1. create new field type in User doctype
  2. then use PUT method /api/resource/User/username
  3. send parameter [“data”:[“field type key”: “field type value”]]
  4. then error Status Code: 500

response

“exc” : “[“Traceback (most recent call last):\n File \”/home/frappe/frappe-bench/apps/frappe/frappe/app.py\”, line 60, in application\n response = frappe.api.handle()\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/api.py\", line 85, in handle\n data = json.loads(frappe.local.request.get_data())\n File \"/usr/lib/python3.6/json/init.py\", line 354, in loads\n return _default_decoder.decode(s)\n File \"/usr/lib/python3.6/json/decoder.py\", line 339, in decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n File \"/usr/lib/python3.6/json/decoder.py\", line 357, in raw_decode\n raise JSONDecodeError(\“Expecting value\”, s, err.value) from None\njson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)\n"]"

it should be in json form like

{"data": {"fieldname": "field type value"}}

eg:

{"data": {"first_name": "John", "last_name": "Doe"}}

yes I do same thing but got error

what is payload type?

I am not getting your point.

sorry my bad! what is ‘content-type’ for request?

import requests

url = "{ your_url }/api/resource/{ path }"

payload = "{\n\t\"first_name\": \"Saurabh\"\n}\n"
headers = {
    'content-type': "text/plain"
    }

response = requests.request("PUT", url, data=payload, headers=headers)

print(response.text)

I use below line
“Content-Type”: “application/json”

:+1: Great

Thanks

update multiple parameter suppose I want update first name and last name then what can i do?

got solution

{\n\t"first_name": “Mohsin…”\n,\n\t"last_name": “Ali…”\n}