Posting JSON to Flask results in 400 Bad Request error

前端 未结 1 1829

I have a post that works getting a json with the parameters and the columns to get from MongoDB, but when I\'m trying to do a LIKE using mongo syntax, it throws:

         


        
相关标签:
1条回答
  • 2021-01-16 13:51

    You didn't post valid JSON. All string values, including keys in objects, need to be quoted. You did not quote $regex.

    {"parameters":{"AddressLine1":{"$regex":"Rio"}},"columns":{"SalesOrderID":1,"TotalDue":1}}
    

    If Flask can't decode the JSON data, it raises a 400 error because the request is invalid.

    0 讨论(0)
提交回复
热议问题