Hai Guys, I Found Some Issue about POST Image To ERPNext using Rest API.
My case, im already create @frappe.whitelist method to upload image using python request here my code.
@frappe.whitelist()
def import_profil_image(cmd,doctype,docname,filename,isprivate,filedata,from_form):
url = "http://xxx.xxx.com/api/method/run_custom_method"
payload = {'cmd': cmd,
'doctype': doctype,
'docname': docname,
'filename': filename,
'isprivate': isprivate,
'filedata' : filedata,
'from_form' : from_form}
headers = {"Content-type": "multipart/form-data"}
res = requests.post(url,data = json.dumps(payload), headers=headers)
return res.json()
this is postman response when im post that method using default login method by erpnext
-
Default Login Method
-
Postman Upload Image
-
Response Status
in case above, i success to upload image to ERPNext… but when im using token authentication response is 403 Forbidden ( Not Permitted) Output is like screenshoot below
-
Postman Post
-
Response Output
its something wrong with my code or something else ? can anyone help me to solve this issue ?
Thanks