Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WitError: Wit responded with status: 400 (Bad Request) #165

Open
harshitmehta opened this issue Feb 24, 2022 · 2 comments
Open

WitError: Wit responded with status: 400 (Bad Request) #165

harshitmehta opened this issue Feb 24, 2022 · 2 comments

Comments

@harshitmehta
Copy link

I am creating a messenger chatbot and I get the following error.

_> File "/app/app.py", line 87, in webhook

response = client.message(msg=text, context={'session_id':fb_id})

File "/app/.heroku/python/lib/python3.9/site-packages/wit/wit.py", line 69, in message
resp = req(self.logger, self.access_token, 'GET', '/message', params)

File "/app/.heroku/python/lib/python3.9/site-packages/wit/wit.py", line 41, in req
raise WitError('Wit responded with status: ' + str(rsp.status_code) +
wit.wit.WitError: Wit responded with status: 400 (Bad Request)_

I know this is a client error and was raised before however I still cannot resolve it.
I am using Server Access Token to create my client.

Also this error is triggered as soon as I enter the webhook.

This is what my webhook looks like:

@app.route('/', methods=['POST'])
def webhook():
    messaging_text = None
    data = request.json
    log(data)
    if data['object'] == 'page':
        for entry in data['entry']:
            messages = entry['messaging']
            if messages[0]:
                message = messages[0]
                fb_id = message['sender']['id']
                text = message['message']['text']
                response = client.message(msg=text, context={'session_id':fb_id})
                handle_message(response=response, fb_id=fb_id)

Kindly help.

@yuzh174
Copy link

yuzh174 commented Feb 24, 2022

@harshitmehta , I will take a look

@yuzh174
Copy link

yuzh174 commented Feb 24, 2022

@harshitmehta, what is the app ID? Have you tried to send the request as a plain HTTP message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants