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 ([minor] allow method object to return its own response object · frappe/frappe@65730d7 · GitHub), 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