API: receive data in Python script API instead of PHP

  • rahulmeethbrother
    Asked on August 11, 2020 at 5:28 AM

    I want to receive data in python script API instead of php, How can I?

  • Girish JotForm Support
    Replied on August 11, 2020 at 8:36 AM

    Sorry, but I'm afraid, there is no direct option to get the script in Python.

    We have a guide that explains this process in detail (it is related to PHP but the procedure will be common for a Python developer as well): How-to-send-Submissions-to-Your-MySQL-Database-Using-PHP 

    In the above example, you can simply replace PHP with your Django code (or any other framework of your choice) and save data in your database. Once you have your data, you can build your Python scripts on top of it.

    Hope this helps.

  • rahulmeethbrother
    Replied on August 11, 2020 at 4:15 PM

    It's really confusing, Let me explain :

    I went through webhooks concept, There you have to provide one PHP page where you can receive your data when people click on submit data.

    The PHP script is just accepting POST data.

    My python API also accept POST request, How I can accept data from webhook to my python API instead of PHP script?

    I am looking for step by step help, Most of the answers in the forum are referring to api.jotform.com but that is so confusing. 

    Can you please provide a clear help on How I can receive the data in my python POST API, as a user submit the form.

     

     

    In detail :

     

    I have one jotform with few fields, I want to achieve this workflow :

     

    1) Embed the form in Flutter( Android )

    2) As soon anyone submit a form, get the submit data in JSON format and send to one python API

    3) Get a response from python API, show the result on the second screen of android app.

     

    Now as you are suggesting, I have to go through this way :

     

    1) Embed the form in Android.

    2) Make a PHP page which accepts the data when anyone submits the form

    3) PHP form will send a request to Android that form is submitted, same time send all data in JSON format to python API.

    4) PHP page has already notified the Android app, Android app will just call python result api and get the result.

    5) show the result on android second screen.

     

    Now I don't want to use PHP as an intermediate between android and Python.  I want to send all data in JSON format to python API as soon someone submits the data in a format, Next Android will call result API to show the result, simple.

     

    How I can achieve this functionality, please be clear in instructions, We are keep sending messages to support and jot form support is just referring to api.jotform.com instead of guiding properly. 

     

     

     

     

     

    Thank you!

  • Girish JotForm Support
    Replied on August 12, 2020 at 7:03 AM

    As far as I can it is not possible to send data to Python API.

    Let me, however, forward this to our back end team regarding such a possibility. Once there is an update we will let you know via this ticket link.

  • Mustafa Culban JotForm Developer
    Replied on August 13, 2020 at 2:32 AM

    Hi,

    I think you don't need any PHP page to get the data. 

    If you have a python API served, you can get the post data from the submission of the form itself.

    You might create an endpoint on your Python API that accept the POST method and you need to put the endpoint link to thank you page of the form as Redirect To External Link.

    Please let me know whether this works for you.

  • rahulmeethbrother
    Replied on August 13, 2020 at 3:31 PM

    Hi, I am using webhook to accept the data, My endpoint function looks like this in flask


    @app.route('/webhook', methods=['POST'])

    def respond():

        print(request.json);

        return Response(status=200)

    But I am getting None as output, while if I am using https://pipedream.com/ as dummy requestbin to accept webhook data, it's working fine.


    Thanks!

  • Mustafa Culban JotForm Developer
    Replied on August 13, 2020 at 4:59 PM

    Hi,

    Could you please let me know what is the output of 'print(request)'?


  • Mustafa Culban JotForm Developer
    Replied on August 14, 2020 at 9:57 AM

    Hi,

    I have investigated and noticed that you are using `request.json` where our WebHook does not sent data in JSON format but send form-data.

    So similar code as below will work for your case;

    `

    @app.route('/webhook', methods=['POST'])

    def respond():

        print(request.form.to_dict());

        return "OK"

    `

    Please let me know if you need further assistance.