Capture POST parameter in API

How can I get the value of POST parameter on a whitelisted API function ?

frappe.local.form_dict didn’t work for me.

@mr-karan,

also check frappe.form_dict

Nope, didn’t help. I’m getting empty response

{"message":"{'cmd': path.to.function.method', 'data': u''}"}

To assist further in debugging, here’s how the data is POSTed

    <!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>title</title>
  </head>
  <body>
      <form id="frmMain" action="http://localhost:8002/api/method/path.to.function.method" method="post">
        
            <input type="submit" id="post_param_id" name="post_param_name" value="" />
        
    </form>              
  
  </body>
  <script type="text/javascript">
    console.log("setting up...");
    document.getElementsByName('post_param_name').value = "checkkk";
    document.getElementById('frmMain').submit();
  </script>
</html>

The very confusing bit is, if I don’t use JS to set the value of input form, it works :confused: but my requirement is to use JS.

If you can use jQuery refer login page

1 Like