Ana içeriğe geç

Update XML Error Response Template

Endpoint

PATCH /apiops/projects/{projectName}/apiProxies/{apiProxyName}/settings/xml-error-template/

Authentication

Requires a Personal API Access Token.

Authorization: Bearer YOUR_TOKEN

Request

Headers

HeaderValueRequired
AuthorizationBearer {token}Yes
Content-Typeapplication/jsonYes

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name

Request Body

Full JSON Body Example

{
"xmlErrorResponseTemplate": {
"xmlErrorResponseTemplateActive": true,
"xmlValue": "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soap:Body>\n <soap:Fault>\n <correlationId>#CORRELATIONID#</correlationId>\n <faultCode>#FAULTCODE#</faultCode>\n <faultString>#FAULTMESSAGE#</faultString>\n <faultStatusCode>#FAULTSTATUSCODE#</faultStatusCode>\n <responseFromApi>#RESPONSEFROMAPI#</responseFromApi>\n </soap:Fault>\n </soap:Body>\n</soap:Envelope>",
"contentType": "text/xml;charset=UTF-8",
"permitSpecialChars": false
},
"deploy": false,
"deployTargetEnvironmentNameList": []
}

Request Body Fields

FieldTypeRequiredDefaultDescription
xmlErrorResponseTemplateobjectYes-XML error template object (see fields below)
deploybooleanNofalseIf true, deploy the API proxy after saving changes
deployTargetEnvironmentNameListarray[string]No-List of environment names to deploy to (required when deploy=true)

xmlErrorResponseTemplate Fields

Partial update

Only the fields present in xmlErrorResponseTemplate are applied. An omitted field (or one sent as null) keeps its stored value, so a call that changes one setting never resets the others — a customised xmlValue survives a call that only flips xmlErrorResponseTemplateActive. The Default column below is what a newly created template starts with, not what an omitted field falls back to on update. An explicit false or an empty string is applied as sent. Unrecognised fields are ignored, so a client that reads the object and posts the whole thing back keeps working unchanged.

FieldTypeRequiredDefaultDescription
xmlErrorResponseTemplateActivebooleanNofalseEnable/disable XML error template
xmlValuestringNo-XML error response template
contentTypestringNotext/xml;charset=UTF-8Content type for error response
permitSpecialCharsbooleanNofalsePermit special characters in template

Template Variables

The XML template can use the following variables (replaced at runtime):

  • #CORRELATIONID# - Request correlation ID
  • #FAULTCODE# - Error fault code
  • #FAULTMESSAGE# - Error fault message
  • #FAULTSTATUSCODE# - HTTP status code
  • #RESPONSEFROMAPI# - Response from backend API (if available)

Default Template

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<correlationId>#CORRELATIONID#</correlationId>
<faultCode>#FAULTCODE#</faultCode>
<faultString>#FAULTMESSAGE#</faultString>
<faultStatusCode>#FAULTSTATUSCODE#</faultStatusCode>
<responseFromApi>#RESPONSEFROMAPI#</responseFromApi>
</soap:Fault>
</soap:Body>
</soap:Envelope>

Note: All fields are optional. Only the fields you send are updated; every field you leave out keeps its stored value.

Response

Success Response (200 OK)

{
"success": true
}

Response Fields

FieldTypeDescription
successbooleanIndicates if the request was successful

When deploy=true is specified:

{
"success": true,
"deploymentResult": {
"deployed": true,
"deployedEnvironments": ["Production", "Staging"],
"failedEnvironments": []
}
}

Deployment Response Fields

FieldTypeDescription
successbooleanIndicates if the request was successful
deploymentResultobjectDeployment result details (only present when deploy=true)
deploymentResult.deployedbooleanWhether deployment was successful
deploymentResult.deployedEnvironmentsarray[string]List of environments where deployment succeeded
deploymentResult.failedEnvironmentsarray[string]List of environments where deployment failed

Error Response (400 Bad Request)

{
"status": "FAILURE",
"resultMessage": "Invalid XML template"
}

Error Response (401 Unauthorized)

{
"status": "FAILURE",
"resultMessage": "Token is not valid!"
}

cURL Example

Example 1: Enable XML Error Template

curl -X PATCH \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/xml-error-template/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"xmlErrorResponseTemplate": {
"xmlErrorResponseTemplateActive": true,
"xmlValue": "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soap:Body>\n <soap:Fault>\n <correlationId>#CORRELATIONID#</correlationId>\n <faultCode>#FAULTCODE#</faultCode>\n <faultString>#FAULTMESSAGE#</faultString>\n </soap:Fault>\n </soap:Body>\n</soap:Envelope>",
"contentType": "text/xml;charset=UTF-8"
}
}'

Example 2: Custom XML Error Template

curl -X PATCH \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/xml-error-template/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"xmlErrorResponseTemplate": {
"xmlErrorResponseTemplateActive": true,
"xmlValue": "<error xmlns=\"http://example.com/error\">\n <id>#CORRELATIONID#</id>\n <code>#FAULTCODE#</code>\n <message>#FAULTMESSAGE#</message>\n <status>#FAULTSTATUSCODE#</status>\n</error>",
"contentType": "application/xml;charset=UTF-8",
"permitSpecialChars": true
}
}'

Example 3: Save and Deploy

curl -X PATCH \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/xml-error-template/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"xmlErrorResponseTemplate": {
"xmlErrorResponseTemplateActive": true,
"xmlValue": "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soap:Body>\n <soap:Fault>\n <correlationId>#CORRELATIONID#</correlationId>\n <faultCode>#FAULTCODE#</faultCode>\n <faultString>#FAULTMESSAGE#</faultString>\n <faultStatusCode>#FAULTSTATUSCODE#</faultStatusCode>\n </soap:Fault>\n </soap:Body>\n</soap:Envelope>",
"contentType": "text/xml;charset=UTF-8"
},
"deploy": true,
"deployTargetEnvironmentNameList": ["Production"]
}'

Example 4: Change One Field (Partial Update)

Only the field in the body is written. The stored xmlValue, contentType and xmlErrorResponseTemplateActive are left exactly as they were.

curl -X PATCH \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/xml-error-template/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"xmlErrorResponseTemplate": {
"permitSpecialChars": true
}
}'

Notes and Warnings

  • Template Variables: Use #VARIABLE# syntax for runtime replacement
  • XML Format: Template must be valid XML
  • Content Type: Default is text/xml;charset=UTF-8 for SOAP
  • Special Characters: When permitSpecialChars=true, special characters are not escaped
  • Active Flag: Set xmlErrorResponseTemplateActive=true to enable template
  • SOAP APIs: Primarily used for SOAP/XML APIs
  • Deploy: When deploy=true, the API proxy is automatically deployed after saving. Provide deployTargetEnvironmentNameList with target environment names

Permissions

User must have API_MANAGEMENT + MANAGE permission in the project.