I'm trying to call an API using django request.post but getting error 405 'Method Not Allowed (POST)'
urls:
path('ciu_consume/<str:br>/<int:qty>/', CiuConsumeView.as_view())
view:
class CiuConsumeView(APIView):
def dispatch(self, *args, **kwargs):
return super().dispatch(*args, **kwargs)
def get(self, request, br, qty):
import pdb;pdb.set_trace()
Response = requests.put('http://inv****.***.***.c***y.in/**/**/***/***/',
data={'br': br, 'qty': 1})
return HttpResponse('Success')
In this I'm getting error 404
If instead of 'def get()' I call 'def post' then also I'm getting same error. Really stuck on this. Any help for this will be helpful.
<form id="form" method="post">{% csrf_token %}
<table class="table table-hover" id="table_id" class="display display nowrap">
<thead>
<tr>
<th>S. No.</th>
<th>barcode</th>
<th>product name</th>
<th>SKU</th>
<th>Quantity</th>
<th>product ID</th>
<th>Colour Code</th>
<th>Status</th>
<th>Mark Loss</th>
</tr>
</thead>
<tbody>
{% for in_dict in in_dict %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ in_dict.br }}</td>
<td>{{ in_dict.p_name }}</td>
<td>{{ in_dict.sku }}</td>
<td>{{ in_dict.qty }}</td>
<td>{{ in_dict.p_id }}</td>
<td>{{ in_dict.clr_code }}</td>
<td>{{ in_dict.status }}</td>
<td><input type="button" name="consume" class="btn btn-success" value="consume" onclick="window.location.href='/api/admin-apis/ciu_consume/{{ in_dict.br }}/{{ in_dict.qty }}/';"></td>
</tr>
{% endfor %}
</tbody>
</table>
</form>
Try adding "https://" in front of the link
So in this case for example if you are hitting the link "http://example.com", try "https://example.com"
Sometimes the request doesn't come through properly to Django because of the upstream server