Search code examples
djangotastypie

Django post with data returns a HTTP 403 forbidden error


I have started an app to post data to django using tastypie. However, I am getting a http 403 forbidden error. Could you please help me to bypass that error ?

Edit: I am getting that error due to my views.py

  </script>
            </head>
            <body>
                <div id="summary">
                    <h1>MultiValueDictKeyError at /api/recipes/item_new/</h1>
                    <pre class="exception_value">&#39;Key \&#39;data\&#39; not found in &lt;QueryDict: {u\&#39;{ data:\\n        {\\n          name: &quot;Something&quot;,\\n          content: &quot;Anything&quot;\\n        }\\n}\\n\&#39;: [u\&#39;\&#39;]}&gt;&#39;</pre>
                    <table class="meta">
                        <tr>
                            <th>Request Method:</th>
                            <td>POST</td>
                        </tr>
                        <tr>
                            <th>Request URL:</th>
                            <td>http://localhost:8000/api/recipes/item_new/</td>
                        </tr>

Solution

  • Are you hitting a CSRF error? You'll want to add the csrf_exempt decorator to your view.