ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

How to call External Web Service



Hello All,
How to call external web service in erpnext.
please give me your valuable help

Thank and regards


Hello @vivek22793. I’m trying to work with a library called zeep. this allows me access to soap services. however I do have challenges configuring for a service that is on https under ERPnext


Thanks for your reply.
Sir i solved this problem.
And its working now.


Hi @vivek22793, i’m new to erpnext, can u please explain in steps how to do that. If anyone know the solution please help me, that will be more helpful for me.


Ya sure, can you tell me what you want do? case?


Thanks @vivek22793 for the reply.
Case: When i make sales order using purchase order, once i click submit button it should send the sales order details in json format to external api. This is my use case. I hope you will understand.


Yes i understood your scenario. I solved this problem using python library (requests) ("url of your external service ", data= json.dumps(your data))
for eg.
import requests
head= {“Accept”:“applicaiton/json”, “Content-type”: “application/json”}
data= {
“name” :,
“login_id” :,
“password” : self.password,
response= http://192.**..***:0000/service/, data= json.dumps(post_data))


Whatever u sent i understood, now the thing is the sales order details have many fields, from that i need some particular fields which i need to send as payload, can u please help me out for this case. Thanks u so much for quick response.


you should also try webhook


Create dictionary and bind data accordingly.
like for eg.
“customer” : self.customer,
“transaction_date”: self.transaction_date,
“item_details”: [{}, {}…]


Thank you, I’ll do this.


Yes sure and let me know if any issue.


sure, thank you


@vivek22793 i got this error when i run this code. url is just sample url

def post_so_to_retailer(so_detail, so):
url = ‘
payload = {
headers = {‘content-type’: ‘application/json’}
r =, data=json.dumps(payload), headers=headers)
return r

Traceback (most recent call last):
File “/opt/bench/erpnext/apps/frappe/frappe/”, line 61, in application
response = frappe.handler.handle()
File “/opt/bench/erpnext/apps/frappe/frappe/”, line 21, in handle
data = execute_cmd(cmd)
File “/opt/bench/erpnext/apps/frappe/frappe/”, line 56, in execute_cmd
return, **frappe.form_dict)
File “/opt/bench/erpnext/apps/frappe/frappe/”, line 1036, in call
return fn(*args, **newargs)
File “/opt/bench/erpnext/apps/erpnext/erpnext/selling/doctype/sales_order/”, line 991, in post_so_to_retailer
AttributeError: ‘str’ object has no attribute ‘customer’


whenever you send data using args it convert all data type as string and send the data
for eg. you are sending data as {“customer”: doc.customer} so your data will go like “{“customer”: doc.customer}”’
so you have to use python eval function.

def post_so_to_retailer(so_detail, so):
so_detail= eval(so_detail)
url = ‘’
payload = {
headers = {‘content-type’: ‘application/json’}
r =, data=json.dumps(payload), headers=headers)
return r


Thank you @vivek22793 , i already got solution for that, i have done the same thing that u mentioned.
I’ll connect back if i get any issues, thank you once again.


Mark solution and close down the topic :slight_smile: