Getting 405 and 415 Error for POSTback URL

cheko
Hi Team,

I am getting below two error(405,415) for POSTBACK URL. However when testing the same with POSTMAN it is working fine. Can you please help debug the issue?

Code
@app.route('/equity/order/status',methods=['POST','GET'],content_types=['application/json','text/plain'])
def webhook_callback():
# This Function will get the webhook update from Kite once order status changes
webhook_message1 = app.current_request.json_body
print("===Webhook===")
print(webhook_message1)
print("==RAW==")
print(app.current_request.raw_body)
print(app.current_request.headers)
print(app.current_request.method)
return(200)

Error (When i save the webhook in my app)
[18/Sep/2020 10:39:34] "HEAD /equity/order/status HTTP/1.1" 405

Error when order is triggered
[18/Sep/2020 10:45:35] "POST /equity/order/status HTTP/1.1" 415 -

The Webhook i am using is

https://xxxxxxxxxxx.ngrok.io/equity/order/status [ xxxx > random chars not shown on purpose]

Success when testing using POSTMAN


Tagged:
  • cheko
    Update:

    i tried to debug using the ngrok console and i see that the 'Content-Type' is coming as 'application/x-www-form-urlencoded' , It has to be 'json' if i am correct?


  • sujith
    It is a form request with data in the body.
    It is easier to test on postbin while setting up your system.
  • cheko
    Update:

    the 405 issue is resolved by adding 'HEAD' in the methods as below,

    methods=['POST','HEAD']

    for the incorrect context-type, it is handled by using json.loads

    json.loads(app.current_request.raw_body)

    Thanks.
Sign In or Register to comment.