Ana içeriğe atla

General Information

Policy Type

policy-xml-transformation

Endpoints

List Policies

GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/

Add Policy

POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Update Policy

PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Delete Policy

DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

List Policies

Endpoint

GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/

Request

Headers

HeaderValue
AuthorizationBearer {token}

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name

Response

Success Response (200 OK)

{
  "success": true,
  "resultList": [
    {
      "apiProxy": {
        "name": "MyAPI",
        "requestPolicyList": [
          {
            "type": "policy-xml-transformation",
            "name": "xml-transform-policy",
            "description": "Transform XML request body",
            "active": true,
            "transformationType": "XML2XML",
            "xsltValue": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n  <xsl:template match=\"/\">\n    <root>\n      <xsl:apply-templates/>\n    </root>\n  </xsl:template>\n</xsl:stylesheet>"
          }
        ],
        "responsePolicyList": [],
        "errorPolicyList": []
      }
    }
  ],
  "resultCount": 1
}

cURL Example

curl -X GET \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/" \
  -H "Authorization: Bearer YOUR_TOKEN"

Add Policy

Endpoint

POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Request

Headers

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy name

Request Body

Full JSON Body Example - XML to XML Transformation
{
  "operationMetadata": {
    "targetScope": "ALL",
    "targetPipeline": "REQUEST",
    "deploy": true,
    "deployTargetEnvironmentNameList": ["production"],
    "order": 1
  },
  "policy": {
    "type": "policy-xml-transformation",
    "description": "Transform XML request body using XSLT",
    "active": true,
    "transformationType": "XML2XML",
    "xsltValue": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n  <xsl:template match=\"/\">\n    <transformed>\n      <xsl:apply-templates select=\"//user\"/>\n    </transformed>\n  </xsl:template>\n  <xsl:template match=\"user\">\n    <user>\n      <id><xsl:value-of select=\"@id\"/></id>\n      <name><xsl:value-of select=\"name\"/></name>\n    </user>\n  </xsl:template>\n</xsl:stylesheet>"
  }
}
Full JSON Body Example - XML to JSON Transformation
{
  "operationMetadata": {
    "targetScope": "ALL",
    "targetPipeline": "REQUEST",
    "deploy": true,
    "deployTargetEnvironmentNameList": ["production"],
    "order": 1
  },
  "policy": {
    "type": "policy-xml-transformation",
    "description": "Convert XML to JSON",
    "active": true,
    "transformationType": "XML2JSON",
    "xmlToJsonUnwrapElement": false,
    "xmlToJsonIgnoreNull": false,
    "xmlToJsonIgnoreEmpty": false,
    "xmlToJsonNumbersAsStrings": false,
    "xmlToJsonUseNullForNil": false,
    "xmlToJsonArrayPathList": [
      "/root/users/user",
      "/root/items/item"
    ]
  }
}

Request Body Fields

operationMetadata
FieldTypeRequiredDefaultDescription
targetScopestringYes-Policy scope: ALL or ENDPOINT
targetEndpointstringNo*-Endpoint path (required if targetScope=ENDPOINT)
targetEndpointHTTPMethodstringNo*-HTTP method (required if targetScope=ENDPOINT)
targetPipelinestringYes-Pipeline: REQUEST, RESPONSE, or ERROR
deploybooleanNotrueWhether to deploy after adding policy
deployTargetEnvironmentNameListarrayNo[]List of environment names to deploy to
orderintegerNonullPolicy execution order (starts from 1)
Enum: targetScope
  • ALL - Policy applies to all endpoints
  • ENDPOINT - Policy applies only to specified endpoint
Enum: targetPipeline
  • REQUEST - Executes in request pipeline (transforms request body)
  • RESPONSE - Executes in response pipeline (transforms response body)
  • ERROR - Executes in error pipeline
Enum: targetEndpointHTTPMethod
  • GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD
policy
FieldTypeRequiredDefaultDescription
typestringYes-Policy type: policy-xml-transformation
descriptionstringNo-Policy description
activebooleanNotrueWhether policy is active
transformationTypestringYesXML2XMLTransformation type: XML2XML or XML2JSON
xsltValuestringNo*-XSLT stylesheet (required if transformationType=XML2XML)
xmlToJsonUnwrapElementbooleanNofalseUnwrap root element in JSON output
xmlToJsonIgnoreNullbooleanNofalseIgnore null values when converting to JSON
xmlToJsonIgnoreEmptybooleanNofalseIgnore empty values when converting to JSON
xmlToJsonNumbersAsStringsbooleanNofalseConvert numbers to strings in JSON
xmlToJsonUseNullForNilbooleanNofalseUse null for xsi:nil attributes
xmlToJsonArrayPathListarrayNo[]XPath expressions for array elements

EnumXmlTransformationType

  • XML2XML - Transform XML to XML using XSLT stylesheet
  • XML2JSON - Convert XML to JSON format

XSLT Stylesheet

XSLT (eXtensible Stylesheet Language Transformations) is used for XML-to-XML transformations. It supports:
  • Template matching
  • Element/attribute selection
  • Value extraction
  • Conditional logic
  • Loops and iterations

XML to JSON Options

  • xmlToJsonUnwrapElement: When true, removes root wrapper element from JSON
  • xmlToJsonIgnoreNull: When true, null values are omitted from JSON
  • xmlToJsonIgnoreEmpty: When true, empty strings/elements are omitted from JSON
  • xmlToJsonNumbersAsStrings: When true, numeric values are converted to strings
  • xmlToJsonUseNullForNil: When true, uses null for xsi:nil="true" attributes
  • xmlToJsonArrayPathList: XPath expressions that identify elements to convert as arrays

Note

  • transformationType is required.
  • If transformationType: XML2XML, xsltValue is required.
  • XML-to-JSON options are only used when transformationType: XML2JSON.

Response

Success Response (200 OK)

{
  "success": true,
  "deploymentResult": {
    "success": true,
    "deploymentResults": [
      {
        "environmentName": "production",
        "success": true,
        "message": "Deployment successful"
      }
    ]
  }
}

cURL Example

curl -X POST \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/xml-transform/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "operationMetadata": {
      "targetScope": "ALL",
      "targetPipeline": "REQUEST",
      "deploy": true,
      "deployTargetEnvironmentNameList": ["production"],
      "order": 1
    },
    "policy": {
      "type": "policy-xml-transformation",
      "description": "Transform XML using XSLT",
      "active": true,
      "transformationType": "XML2XML",
      "xsltValue": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"/\"><root><xsl:apply-templates/></root></xsl:template></xsl:stylesheet>"
    }
  }'

Update Policy

Endpoint

PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Request

Headers

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy name

Request Body

Full JSON Body Example
{
  "operationMetadata": {
    "targetScope": "ALL",
    "targetPipeline": "REQUEST",
    "deploy": true,
    "deployTargetEnvironmentNameList": ["production"],
    "order": 1
  },
  "policy": {
    "type": "policy-xml-transformation",
    "description": "Transform XML request body using XSLT",
    "active": true,
    "transformationType": "XML2XML",
    "xsltValue": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n  <xsl:template match=\"/\">\n    <transformed>\n      <xsl:apply-templates select=\"//user\"/>\n    </transformed>\n  </xsl:template>\n  <xsl:template match=\"user\">\n    <user>\n      <id><xsl:value-of select=\"@id\"/></id>\n      <name><xsl:value-of select=\"name\"/></name>\n    </user>\n  </xsl:template>\n</xsl:stylesheet>"
  }
}
Note: Request body structure is the same as Add Policy. All fields should be provided for update.

Response

Success Response (200 OK)

{
  "success": true,
  "deploymentResult": {
    "success": true,
    "deploymentResults": [
      {
        "environmentName": "production",
        "success": true,
        "message": "Deployment successful"
      }
    ]
  }
}

Delete Policy

Endpoint

DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Request

Headers

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy name

Request Body

Full JSON Body Example
{
  "operationMetadata": {
    "targetScope": "ALL",
    "targetPipeline": "REQUEST",
    "deploy": false
  }
}

Response

Success Response (200 OK)

{
  "success": true,
  "deploymentResult": {
    "success": true,
    "deploymentResults": []
  }
}

Notes and Warnings

  • Transformation Type:
    • XML2XML - Uses XSLT stylesheet for transformation (requires xsltValue)
    • XML2JSON - Converts XML to JSON format (uses XML-to-JSON options)
  • XSLT Stylesheet:
    • Must be valid XSLT 1.0 or 2.0
    • Supports template matching, element selection, value extraction
    • See XSLT documentation for detailed syntax
  • XML to JSON Options:
    • xmlToJsonUnwrapElement: Remove root wrapper element from JSON
    • xmlToJsonIgnoreNull: Omit null values from JSON output
    • xmlToJsonIgnoreEmpty: Omit empty strings/elements from JSON
    • xmlToJsonNumbersAsStrings: Convert numeric values to strings
    • xmlToJsonUseNullForNil: Use null for xsi:nil="true" attributes
    • xmlToJsonArrayPathList: XPath expressions for array conversion
  • Array Paths: XPath expressions in xmlToJsonArrayPathList identify elements to convert as JSON arrays
  • Performance: XML transformation adds processing overhead. Use for necessary transformations only.
  • Pipeline:
    • REQUEST pipeline transforms request body before forwarding
    • RESPONSE pipeline transforms response body before sending to client
  • Error Handling: Invalid XSLT or malformed XML will cause transformation to fail
  • Deployment: Policy changes require deployment to take effect. Set deploy: true or deploy manually.