Replies: 1 comment 4 replies
-
Validation of XML is currently not supported out of the box, so you'll have to handle this yourself. You can instead receive that raw body via the @dataclass
class Band(BaseModel):
id: int
name: str
genre: str
@post(path="/demo3", media_type="application/xml")
async def demo3(
body: bytes,
) -> str:
band = parse_xml(body) # some function that parses your XML
print("id="+data.id)
return "ok" |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am trying to post data in XML
But it looks this is not so easy? I get a HTTP Error:
{"status_code":400,"detail":"JSON is malformed: invalid character (byte 0)"}
It looks like the xml data can not be converted into json. I guess I need some kind of extra code to parse the request body by myself? Can someone help me how to do this?
Beta Was this translation helpful? Give feedback.
All reactions