Erpnext rest api

Hi everyone
I want to integrate erpnext with angular. before i start I need to test erpnext rest api using postman.
I could logged in to erpnext using postman by
http://192.168.1.63/api/method/login?usr=myEmail&pwd=myPassword
I got the following response
{ "home_page": "/desk", "message": "Logged In", "full_name": "Web Master" }
now I can access list of items, and customers
by sending get request to ``http://192.168.1.63/api/resource/Customer```
but I can’t create a customer using POST request with body

{
    "data": [
        {
            "name": "غلام "
        }
    ]
}

I changed body to the following format but still same error

{
    "data": [
        {
            "customer_name": "غلام "
        }
    ]
}

the error is Status 500 INTERNAL SERVER ERROR
I couldn’t find a solution from this link
https://frappe.io/docs/user/en/guides/integration/rest_api

any help?

I get the same error when I create Item

for the post Request to create new Customer, Item or any record, you have to send all Mandatory Fields.

for customer, try following. and if you apply naming series, you have to send that parameter too.

data={“customer_group”: “Individual”, “territory”: “India”, “customer_type”: “Individual”, “customer_name”: “Any Name” }

1 Like

also try to post the full error log. will help others to understand what’s causing the error

1 Like

hi @adnan thanks for replying
I don’t get any error in body,

you’ll get full log in Body, Raw or Preview.

Left side of this image

1 Like

the Json you are sending has some issue.

share what you are sending to create a document

1 Like
{
	"data":
	{
		"customer_group": "Individual",
		"territory": "India", 
		"customer_type": "Individual", 
		"customer_name": "Zia" 
	}
}
http://192.168.1.63/api/resource/Customer

share your Postman screen shot

what’s in the URL

1 Like

You have to provide json object as data parameter.

2 Likes

Thank you
it worked