---
schema_version: "1"
id: 1252845821c66d068be7f470ae45cc977bf344ec38a814365c361042b4f9a1d0
title: Rules Testing with jsonxform/transformation endpoint
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_wave_templates/guides/reference/bi-templatesdev-jsonxform-transformation.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/guide/bi-templatesdev-jsonxform-transformation.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 2822f62ff6dc89e1de53ecc2b8723697f6b1d431208c54b8c8903a670e5d9947
products:
  - Analytics Templates Developer Guide
  - analytics
---

# Rules Testing with jsonxform/transformation endpoint

Test the results of a rule before deployment by calling the `jsonxform/transformation` endpoint.

## Process for Using jsonxform/transformation

Use cURL or Postman to execute a `Post` call on the `/services/data/v51.0/jsonxform/transformation` REST endpoint. See the examples for starting points on what the POST request body must contain.

If the rule works, the POST response contains the transformed JSON results. If the rule doesn’t work, the POST response contains any errors with guidance to fix the rule.

The following examples show how you can take advantage of the built-in tokens we provide.

## Example: Post Transform

A “put” rule that adds a `name/value` pair to the JSON.

```nolang
{
	"document": {
		"user": {
			"firstName": "${User.FirstName}",
			"lastName": "${User.LastName}",
			"userName": "${User.UserName}",
			"id": "${User.Id}",
			"hello": "${Variables.hello}"
		},
		"company": {
			"id": "${Org.Id}",
			"name": "${Org.Name}",
			"namespace": "${Org.Namespace}"
		}

	},
	"values": {

		"Variables": {
			"hello": "world"
		}
	},
	"definition": {
		"rules": [{
			"name": "Example",
			"actions": [{
				"action": "put",
				"description": "add hobby to user",
				"key": "hobby",
				"path": "$.user",
				"value": "mountain biking"
			}]
		}]
	}
}
```

## Example: Constant Array

Tests an array function (`contains`) to determine the right value to add to the final JSON.

```nolang
{
	"document": {
		"user": {
			"firstName": "${User.FirstName}",
			"lastName": "${User.LastName}",
			"userName": "${User.UserName}",
			"id": "${User.Id}",
			"hello": "${Variables.hello}"
		},
		"company": {
			"id": "${Org.Id}",
			"name": "${Org.Name}",
			"namespace": "${Org.Namespace}"
		}

	},
	"values": {
		"Variables": {
			"hello": "world",
			"choices": ["Products", "Cases"]
		}
	},
	"definition": {
		"constants": [{
			"name": "ConstantTest",
			"value": "${array:contains(Variables.choices, 'Products') ? 'Products' : 'No Products'}"
		}],
		"rules": [{
			"name": "Example",
			"actions": [{
				"action": "put",
				"description": "add hobby to user with constant",
				"key": "hobby",
				"path": "$.user",
				"value": "${Constants.ConstantTest}"
			}]
		}]
	}
}
```

## Example: Macro Transform

Tests a macro with a rule.

```nolang
{
	"document": {
		"user": {
			"firstName": "${User.FirstName}",
			"lastName": "${User.LastName}",
			"userName": "${User.UserName}",
			"id": "${User.Id}",
			"favorite": null
		}
	},
	"values": {},
	"definition": {
		"macros": [{
			"namespace": "jsonTest",
			"definitions": [{
				"name": "setNodeByPath",
				"parameters": [
					"jsonPath",
					"value"
				],
				"actions": [{
					"action": "set",
					"path": "${p.jsonPath}",
					"value": "${p.value}"
				}]
			}]
		}],
		"rules": [{
			"name": "Example",
			"actions": [{
					"action": "put",
					"description": "add hobby to user",
					"key": "hobby",
					"path": "$.user",
					"value": "mountain biking"
				},
				{
					"action": "eval",
					"description": "Set the value of 'favorite' with the value from 'hobby'",
					"path": "$.user.hobby",
					"value": "${jsonTest:setNodeByPath('$.user.favorite', Rules.CurrentNode)}"
				}

			]
		}]
	}
}
```

For reference on the `jsonxform/transformation` REST endpoint, see [JsonXform Transformation Resource](https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_rest.meta/bi_dev_guide_rest/bi_resources_jsonxform_transformation.htm) in the Analytics REST API Developer Guide.
