ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

How to add arguments for API RPC calls?


#1

How do I add arguments for an RPC call?

I’m calling /api/method/frappe.desk.tags.get_tags and receiving the error TypeError: get_tags() takes exactly 2 arguments (0 given)


Frappeclient RPC
#2

Can you share your code? or is it just the /api/method/frappe.desk.tags.get_tags ?

Generally you’ll need to make a session with something like this:

client = FrappeClient("http://site_address....", "login_id", "password")

Then you can do this:

args = {"key": "value", "key": "value"}
tags = client.get_api("frappe.desk.tags.get_tags", args)

You need to do client.(api call) in order to pass self, which is the first argument. Then you pass the rest of the args needed in the args variable.

Let me know if this helps!


#3

I know this response is a bit “late” form the original posting, and popped up as a result when I was trying to solve the same issue. SInce I solved it, I am logging an answer for the record and closing the issue.

In this case you need to know the arguments that are required, so that you can pass the correct argument names and values.

If you inspect the code, this method now requires 3 arguments:
doctype, txt, cat_tags

Exploring the data types each one requires is beyond the scope of this answer, however, your request should look like this:

http://[SERVER IP]/api/method/frappe.desk.tags.get_tags?doctype="[DOCTYPE NAME]"&txt="[VALUE OF TXT]"&cat_tags="[VALUE OF CAT_TAGS]"

You should then get an appropriate response!


#4