API

Article number: 310347

JSON To XML Converter API

This web-service allows an API outputting JSON to be converted to XML for use in a data island.

The endpoint for the web-service is: /ws/JSON2XMLWS.aspx

Parameters

  • j2x_url - The API endpoint to be converted. (Mandatory)
  • j2x_method - Whether to call API endpoint via GET or PUT (Optional). [Values: GET|PUT, Default: GET]
  • j2x_raw - Whether to output raw data from the API without XML conversion (Optional). [Values: true|false, Default: false]
  • j2x_mime - The mime type to use for raw data output (Optional). [Values: <mime-type>, e.g. text/plain, application/json, Default: application/xml]
  • j2x_cache - How long to cache the API response for in minutes (Optional). [Values: -1, 0 to n (-1 = no caching), Default: -1]

API Parameters

All other querystring parameters supplied to this web-service are relayed to the API endpoint as querystring parmeters.
All other values posted to this web-service are relayed to the API endpoint as form data in the request body.
n.b. Any parameter whose name is prefixed by 'j2x_' is not relayed to the API endpoint.

Custom HTTP Headers

Some API endpoints require custom http headers for authorisation. These can be supplied using two optional parameters. For example, say the API endpoint requires a http header called 'subscription-key' with value '0123456789'.

This would be supplied using two parameters:

  • j2x_header1_name=subscription-key
  • j2x_header1_value=0123456789

Up to 99 headers can be added by replacing 'header1' with 'header2' and so on.

Example

http://my.domain.name/ws/JSON2XMLWS.aspx?j2x_url=http://api.domain.name/endpoint&j2x_header1_name=subscription-key&j2x_header1_value=1234567890&j2x_cache=5&topic=xxx

Calls API endpoint at http://api.domain.name/endpoint by GET with querystring parameter 'topic=xxx' and custom http header 'subscription-key=1234567890'. The API response is converted from JSON to XML and then returned to the caller.

Caching

Caching within this web-service is global across the web-server. If an API has usage limits, multiple sites on the same web-server can share the same cached API requests to prevent triggering usage blocks. The caching within data islands is 'per site', so using caching within data islands instead would result in multiple sites potentially making identical requests to the same endpoints.

Authorisation

Calls to this web-service can be secured using the built-in basic authorisation features within Sitekit CMS, to prevent use by third parties.

Related questions