strongloop / strong-remoting

Communicate between objects in servers, mobile apps, and other servers.
www.strongloop.com
Other
105 stars 93 forks source link

XML Validation Error #461

Closed guneraykut closed 4 years ago

guneraykut commented 5 years ago

I want to accept and save XML data through the model REST api. When I select "Parameter content type" and "Response Content Type" "application/xml" or "text/xml", I got following validation error.

   <error>
    <statusCode>422</statusCode>
    <name>ValidationError</name>
    <message>The `testmodel` instance is not valid. 
             Details: `type` can't be blank (value: undefined); 
             `metric` can't be blank (value: undefined); 
             `valid` can't be blank (value: undefined); 
             `registerDate` can't be blank (value: undefined).
    </message>
    .....
   </error>

And my post data is

<?xml version="1.0"?>
<testmodel>
    <type>testType</type>
    <metric>testMetric</metric>
    <valid>true</valid>
    <registerDate>Thu Jan 17 2019 10:25:59</registerDate>
</testmodel>

It works when selecting Parameter content type" and "Response Content Type" as JSON.

I set remoting.rest.xml to true under config.json file. Responses are okay with XML but post and put payload does not excepted due to validation error. I also added

"parse": {
    "express-xml-bodyparser": {"params": { "limit": "1024kb" }}
},

to middleware.json file but no luck.

Thanks

bajtos commented 5 years ago

I am afraid we support XML in responses only, LoopBack/strong-remoting is not able to parse XML bodies.

I think your solution of adding express-xml-bodyparser should work, unfortunately we don't have bandwidth to investigate this ourselves. If you happen to find the source of the problem and can open a pull request to fix it, then I am happy to help you to get the changes landed.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.