0

I am trying to pass some parameters from my django template to kaltura .

Here is what I have done so far .

        <form id="kalturarequest" action="www.kaltura.com/api_v3/" method="post" enctype="multipart/form-data">
        {% csrf_token %}
            <input type="hidden" id="ks" name="ks" value=""/>
            <input type="hidden" id="service" name="service" value="uploadToken" /> 
            <input type="hidden" id="action" name="action"  value="upload"/>
            <input type="hidden" id="uploadTokenId" name="uploadTokenId"  value=""/>        
            <input type="file" name="fileData" id="fileData"/>      
            <input type="submit"  onclick="return Checkfiles();"  class="btn-primary upload-btn-height" id="uploadBtnNew" value="Submit" />
        </form> 

But instead of posting form to www.kaltura.com/api_v3/ address this is posting the form to mysite itself .

PLease help me how can I make it working so that this form should POST to www.kaltura.com/api_v3/ instead of localhost:8000/www.kaltura.com/api_v3/

llazzaro
  • 3,970
  • 4
  • 33
  • 47
RnD
  • 15
  • 1
  • 6
  • possible duplicate of [HTML Form POST Cross Domain](http://stackoverflow.com/questions/8497609/html-form-post-cross-domain) – llazzaro Oct 31 '13 at 17:35
  • Can we do it without passing protocol ? – RnD Oct 31 '13 at 17:38
  • you are passing post request to www.kaltura.com/api_v3/ using simple html post request. i do not think it is good approach .anyone can see your tokenId , service name by just seeing source code in browser ..do not you need to secure your form data ?? – Prashant Gaur Oct 31 '13 at 18:04

3 Answers3

2

You forgot the protocol (http or maybe https?):

    <form id="kalturarequest" action="http://www.kaltura.com/api_v3/" method="post" enctype="multipart/form-data">
manonthemat
  • 6,101
  • 1
  • 24
  • 49
  • agree but can we do without protocol ? – RnD Oct 31 '13 at 17:37
  • 1
    If you omit the protocol, the http-server will assume it's a local document. From the current path it'll look for a directory named "www.kaltura.com" and the subdirectory "api_v3" to post your form to its index file. So yes, you'll have to specify the protocol if you want to communicate with an external server. – manonthemat Oct 31 '13 at 17:45
2

To make this work and omit protocol place two slashes in the beginning:

//www.kaltura.com/api_v3/

Now the the form submit location will be correct (it will use the same protocol as url of the page containing the form).

If you're curious, look here: https://www.rfc-editor.org/rfc/rfc3986#section-3

Community
  • 1
  • 1
Kzhi
  • 380
  • 1
  • 2
  • 11
0

If you are creating a form and not validating it in Django then there is no need to include the {% csrf_token %}.

My advice would be to create a Django form, validate the users input in your view, then use a library like requests (or the python library Kaltura provides) to make the API request.

Tom
  • 1,986
  • 2
  • 18
  • 29