Restful api calls and passing parameters

Anybody here can help this newbie in passing a single parameter required by a server side whitelisted python function using the RESTful API.

According to the instructions I call this function from http using a GET method:
http://{myserverinstance}/api/method/dotted.path.to.function

Is there a way to pass a single argument required by Python serverside whitelisted:

@frappe.whitelist
def function(arg1)
# awesome code requiring arg1 goes here
return awesome_result_that_used_arg1

Should it be a POST calling this, but with body containing the argument in which structure?

1 Like

GET:
http://{myserverinstance}/api/method/dotted.path.to.function?arg1=abc

POST (should be):
http://{myserverinstance}/api/method/dotted.path.to.function
and parameter as json string

{
“arg1”: “abc”
}

4 Likes

Thanks, I managed to resolve before your reply but had not posted solution!

I am updating this data here: Coding Guide to Frappe Part 2