Trying to create an endpoint with a 'generic' parameter #8158
Replies: 4 comments
-
Yep, if you know it's a dict, declare as If it might be a I received an email notification with the same answer by @dmontagu, but I don't see it here... 🤷♂️ |
Beta Was this translation helpful? Give feedback.
-
@tiangolo I deleted because I wasn’t sure if it would work if you want a dict with arbitrary keys at the top level, and I couldn’t test it out right now (didn’t want to leave unhelpful advice if I was wrong). I figured if you annotate with |
Beta Was this translation helpful? Give feedback.
-
Thank you for the quick answers! I appreciate it. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help @dmontagu ! 🌮 🍰 And thanks @ShawnClake for reporting back and closing the issue 🎉 |
Beta Was this translation helpful? Give feedback.
-
Description
I'm trying to build an API using FastAPI that needs to integrate with another (undocumented) system which I do not have control over. For this reason, I need to be able to create an endpoint that I can use as an integration point without knowing what POST body data will be sent to my API. Is this possible using FastAPI? Am I able to create a sort of 'generic' parameter for an endpoint function which will capture any POST body data into a dictionary?
Thanks in advance.
To clarify:
This is simply so that I can reverse engineer the system I don't have control over. Once I see what data is being sent, I can rewrite the endpoints to be more explicit.
Beta Was this translation helpful? Give feedback.
All reactions