As explained in this link (How to receive data from a POST request in frappe - #4 by revant_one)
i am also trying same way but i don’t know why its not working. i am trying for method which have parameter .
my api method code is:
@frappe.whitelist(allow_guest=True)
def sps_erpnext_rest_api(filters):
print"@@@@@@@ filter @@@@@@@@@“, filters, type(filters)
if filter is not None:
q= “”“select * from tabxyz
where name= ‘%s’””" %(str(filters[0][‘name’]))
else: q= “”" select * from tabxyz
"“”
k=frappe.db.sql(q,as_dict=True)
print"@@@@@@@@@@ REST Called @@@@@@@@@@@@@@@@",
return k
And api calling code is:
import request, json
head= { “Content-type”: “application/json”}
my_params= [{‘name’: ‘TTTT5’}]
url= “http://xxx.xxx.x.xxx:8000/api/method/sps.sps.api.sps_erpnext_rest_api”
response= requests.post(url, data=json.dumps(my_params) )
print response
In error am getting sps_erpnext_rest_api() takes 1 argument 0 is given.
when am trying sps_erpnext_rest_api() without any parameter its working fine.
So can you guys help me how to bind parameters
Thanks and regards
Vivek