0

what is XML Gateway for POST API

i am working in a web application to register a company online using XML gateway. but i don't have any idea to work with XML, i have a link contains of XSD or XML schemas, here is the link. i dont have any idea how to test and get started. because there are no any http link or else to test any API in the postman. just XSD and XML files there are.

please anyone know how to work with XML gateway or XSD/XML Schemas or any link to follow where may i get the process to integrate XML gateway with django to make a POST request.

will be thankful for your answer.

azhar
  • 351
  • 3
  • 13

1 Answers1

0

Try using the xmltodict module's parse() method to obtain the XML as JSON which will be suitable with DRF API structure.

Yusuf Ertas
  • 261
  • 1
  • 5
  • i am not getting your points. i am talking about API's, how can i make a POST request based on given XSD which is in http://xmlgw.companieshouse.gov.uk/SchemaStatus – azhar Dec 25 '21 at 22:20
  • i mean if i want to check one of the XSD like a rest API. how can i. and is there any tool like postman to check the API. basically i want to know how to get started with these XSD to make a POST request. – azhar Dec 25 '21 at 22:23
  • As far as I understand, you want to make a contribution to this API with a POST request. If so, I would first suggest doing a GET request and parse the data into JSON or Python's native dictionary to understand the data structure. Then you can construct your own XML and send a POST request using the method mentioned in [this link](https://stackoverflow.com/questions/12509888/how-can-i-send-an-xml-body-using-requests-library). – Yusuf Ertas Dec 25 '21 at 22:30
  • how to make a GET request.? – azhar Dec 26 '21 at 09:09
  • You can do it like this: ` import requests import xmltodict url = "http://xmlgw.companieshouse.gov.uk/v1-0/schema/ChargeSearch-v2-7.xsd" content = requests.get(url).content data_json = xmltodict.parse(content.decode()) print(data_json['xs:schema'].keys()) ` This will show you the individual keys in the JSON schema which is similar to a Python dictionary. Then you can dig deeper into the indvidual keys to understand this structure better. – Yusuf Ertas Dec 26 '21 at 10:39
  • okay. thanks i ll try. and let you know. thanks a lot. – azhar Dec 26 '21 at 10:41