Using Sinatra with Webhook to retrieve the url of one file upload

  • Profile Image
    Asked on November 19, 2015 at 11:40 AM

    I am trying to obtain the url direction of a file (uploaded) located in jotform. I use Sinatra in the Backend to control the /POST for jotform, the webhook is already working and i receive the response from jotform.

    The response has a format that i can not parse in ruby using JSON.parse( I think it happens because of the format used in that object. So i want to know what is the format of that object to parse into an json object and retrieve the url with the location of the file.

    Example of the without the parsing:

    $ rackup -p 8080 launch_server.rb 

    [2015-11-19 11:52:24] INFO  WEBrick 1.3.1

    [2015-11-19 11:52:24] INFO  ruby 2.1.2 (2014-05-08) [x86_64-linux-gnu]

    == Sinatra (v1.4.6) has taken the stage on 4567 for development with backup from WEBrick

    [2015-11-19 11:52:24] INFO  WEBrick::HTTPServer#start: pid=9081 port=4567


    Content-Disposition: form-data; name="formID"




    Content-Disposition: form-data; name="submissionID"




    Content-Disposition: form-data; name="webhookURL"



    Content-Disposition: form-data; name="ip"



    Content-Disposition: form-data; name="formTitle"


    Upload Files


    Content-Disposition: form-data; name="pretty"


    Full Name: , E-mail:, Order :, ID:28, Upload your Prescription:Screenshot from 2015-09-19 08:58:09.png


    Content-Disposition: form-data; name="username"




    Content-Disposition: form-data; name="rawRequest"


    {"slug":"submit\/53165035132647\/","q5_fullName5":{"first":"","last":""},"q7_email7":"","q8_order8":"","q10_id":28,"preview":"true","event_id":"1447950157883_53165035132647_fnvutIt","q1_uploadYour":["http:\/\/\/uploads\/jdelgado\/53165035132647\/323759367249625573\/Screenshot from 2015-09-19 08_58_09.png"]}


    Content-Disposition: form-data; name="type"




    localhost - - [19/Nov/2015:11:52:50 VET] "POST /webhook/heywatch HTTP/1.1" 200 0

    - -> /webhook/heywatch


    Thanks beforehand!

  • Profile Image
    Answered on November 19, 2015 at 01:01 PM

    I'm sorry but not truly familiar with Sinatra and webhook. I was able to locate a small sample on the web on how to send and receive request through POST:

    To get the URL of any upload file, you can use the following code sample

    $url = "".$formid."/".$submission_id."/".$upload;

    Please let us know if this helps.