'Respond to Instagram webhook in Django

I set the callback-url for Instagram webhook, and when Instagram Get my callback-url I should respond to the hub.challenge to verify. Instagram GET request to my endpoint URL:

GET https://callback_url/webhooks?
  hub.mode=subscribe&
  hub.challenge=1120110039&
  hub.verify_token=meatyhamhock

My code in vews.py:

def getInstagramWebhook(request):
    if request.method == "GET":
        mode         = request.GET.get("hub.mode")
        challenge    = request.GET.get("hub.challenge")
        verify_token = request.GET.get("hub.verify_token")
        return challenge

But I have this error:

The URL couldn't be validated. Response does not match challenge, expected value="1120110039", received="\u003C!DOCTYPE html>\n\u003Chtm..."

I tried JsonResponse, HttpResponse, and redirect but not work



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source