You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm testing an existing XML-based rest API. The XML string is not sent with:
.post("/my/uri", "xml")
I looked into api-easy.js, and I think I see the issue. The _request function expects data to be an object. Fixing this would not be as simple allowing the body to be either an object or string -- as this could possibly conflict with the uri parameter.
One possible solution is to have the body continue to be an object, but for unkown mime types, encapsulate the data in an object, like such: {"body": "xml"}.
The text was updated successfully, but these errors were encountered:
I think your fork would work, but I believe there may be a subtle bug. If no URI is passed in and the data is passed in as a string, then the uri variable would be assigned the data.
I think as long as you pass in the uri explicitly, your fix would work.
One hack is to wrap your xml string in a Buffer (new Buffer(xmlString)). From the perspective of api-easy, it behaves like a string but it is an object, so the string logic is not triggered.
You can wrap it as a function, so it looks less ugly. function xmlBody (xmlString) { return new Buffer(xmlString); }
However, it still does not feel right. I think api-easy is not really intended to be used with XML but only with JSON.
I'm testing an existing XML-based rest API. The XML string is not sent with:
.post("/my/uri", "xml")
I looked into api-easy.js, and I think I see the issue. The _request function expects data to be an object. Fixing this would not be as simple allowing the body to be either an object or string -- as this could possibly conflict with the uri parameter.
One possible solution is to have the body continue to be an object, but for unkown mime types, encapsulate the data in an object, like such: {"body": "xml"}.
The text was updated successfully, but these errors were encountered: