Reputation: 46
I'm Trying to get Watson Assistant to return a JSON response from an external API (Ubuntu 18.04 server) running on Apache2 and Flask for Python. When I test the response in Watson Assistant I get this error {"response_code":405,"message":"Webhook response is not JSON Object","content_type":"text/html; charset=utf-8"}.
I've made sure that Flask is passing the response in JSON response = app.response_class(response=json.dumps(x), status=200, mimetype="application/json")
And with Apache2
I've searched everywhere and cannot find answer to why Watson is not accepting my JSON.
Is there something I am missing?
Thanks
Upvotes: 1
Views: 540
Reputation: 46
I'm running this on my own Ubuntu Server. As far as I can tell, Watson Assistant likes your parameters to be parsed like this... A bit unusual.
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Params(BaseModel):
# For your parameters. Eg
# time: str
# for non-required. Eg
# age: int = 0
@app.post("/")
async def root(req_data: Params):
if req_data.age == 18:
return {"message": "You are 18!"}
Upvotes: 1