Jump to content

Xabier

Members
  • Content Count

    1
  • Joined

  • Last visited

Everything posted by Xabier

  1. Hello, I am testing MARS to consume a XML file in a Post request. I get the following error: "Internal server error: [EInvalidCast] Invalid class typecast" My definition for the function is similar to one in the example EKON22: [POST, Path('recordAge2'),Consumes(TMediaType.APPLICATION_XML), Produces(TMediaType.APPLICATION_JSON)] function WhatsMyAge2([BodyParam] ARecord: TMyRecord): TJSONObject; and after watching how MARS creates the xml file (for a GET request) I send in my POST request the following XML (I also specify in Content-Type that is an application/xml): <DATAPACKET Version="2.0"> <METADATA> <FIELDS> <FIELD attrname="Firstname" fieldtype="string" WIDTH="100" /> <FIELD attrname="Lastname" fieldtype="string" WIDTH="100" /> </FIELDS> <PARAMS CHANGE_LOG="1 0 4 2 0 4 3 0 4 4 0 4" /> </METADATA> <ROWDATA> <ROW RowState="4" Firstname="Andrea" Lastname="Magni" /> </ROWDATA> </DATAPACKET> I have try with different combinations for the XML file but with no success. Any help would be appreciated. Thanks in advance. PD:It is weird to me that instead of "Consumes(TMediaType.APPLICATION_XML)" if I define"APPLICATION_JSON" it accepts the request (the xml content) but it does not map the content of the xml file to a record but no error arises, also if I define the function with NO "Consumes" section and in the body I specify that I will receive a String it also works, so may be the question is if MARS can parse the XML to a record or how it does. (The next question will be how to parse for multiple Firstname, Lastname).
×