How to create an xml endpoint in a frappe app?

I’d like to create an endpoint that returns dynamic xml from an app. The goal is to integrate with ShipStation. The documentation shows how to create a page that inherits the frappe theme and template, but not a raw doc. How would I go about this?

There is no easy way to allow a regular whitelist to return a Response Object.

So I just fixed it (https://github.com/frappe/frappe/commit/65730d7bcfb65cee20f2acb7f46bf79bee1f740d), so you can now make an endpoint by creating a whitelisted function

@frappe.whitelist()
def get_xml(args):
  from werkzeug.wrappers import Response
  response = Response()
  response.mimetype = 'text/xml'
  response.charset = 'utf-8'
  response.data = '<xml></xml>'

  return response

check if this works (after updating from the latest develop)

5 Likes

Hi @rmehta

This worked great, was also looking for this feature…can this be added to the master branch?

regards
Hemant