Skip to main content

Push updates - JSON samples

Sending content updates to a Flex document is done with a JSON format and API method documents/{id}/contents/push

This page shows a few examples of JSON content.


Example 1 - Pushing some strings

Sending strings to Flex is easy. Simply compile all strings to update into a JSON payload.

Some strings may already exist in Wordbee and will be updated, some may not yet exist and will be added. You do not need to think about such mundane details 🙂 

CODE
{
  "header": { "mode": "partial" },
  "segments": [

  {
     "key": "1000-10",
     "texts": { "en": { "v": "Hello world"} }
  },

  {
     "key": "890-5",
     "texts": { "en": { "v": "Please click here"} }
  },

  {
     "key": "890-6",
     "format": "html_1",
     "texts": { "en": { "v": "Go to the <bold>Settings</bold> screen. Then click the Edit button."} }
  },

  {
     "key": "890-7",
     "parent": "890-6",
     "format": "html_1",
     "texts": { "en": { "v": "Fill in your details and click the Submit button."} }
  },

  {
     "key": "890-5",
     "texts": { "en": { "v": "Please click here" }, "de": { "v": "Bitte hier klicken" } }
  }

  ]
}


Example 2- Partial update of a single translation

A minimal partial update of the German translation "de" of a segment.

This example shows that you do not need to supply the source language text with updates. However, the system will fail if the "key" does not refer to an existing segment: To add new segments, the source text is required.

JS
{
  "header": {
     "mode": "partial"
  },
  "segments": [
  {
     "key": "k22992",
     "texts": {
       "de": {"v": "Guten Tag"}
     }
  }
  ]
}


Example 3 - Partial update of source and translation

It may be easiest for you to include all texts of a segment with each push. Wordbee will automatically find out what has changed.

Here we send a segment with all the 3 languages we have on records:

CODE
{
	"header": {
		"mode": "partial"
	},
	"segments": [
    {
		"key": "k22992",
		"texts": {
			"en": { "v": "Good day" },
			"fr": { "v": "Bonjour" },
			"de": { "v": "Guten Tag" }
		}
	}
   ]
}


Example 4 - Full update with metadata

It may be easiest for you to include all texts of a segment with each push. Wordbee will automatically find out what has changed.

CODE
{
	"header": {
		"mode": "full"
	},
	"segments": [{
		"key": "k22992",
		"texts": {
			"en": {
				"v": "Hello world"
			},
			"de": {
				"v": "Guten Tag"
			}
		}
	},
	{
		"key": "k772",
		"format": "html_1",
		"texts": {
			"en": {
				"v": "Hello world",
				"cfs": [{
					"t": "Section",
					"id": 1,
					"v": "My value"
				}],
				"lbls": [{
					"t": "Section",
					"id": 4043,
					"v": 20
				}],
				"cms": [{
					"v": "Please help me!"
				}]
			},
			"de": {
				"v": "Guten Tag Welt"
			}
		},
		"cfs": [{
			"t": "Via 2",
			"v": "Quality issue"
		}]
	}]
}

Example 5 - Update metadata only

Setting the "v" property in a language to null (or simply omitting the property) will not modify the current text in that language. This is perfect if you only want to update some meta data.

In the example below we add a comment to the German translation. As you can see we do not specify the German text at all, simply because we do not want to change it.

CODE
{
	"header": {
		"mode": "full"
	},
	"segments": [{
		"key": "k22992",
		"texts": {
			"de": {
				"cms": [{
					"v": "Please help me!"
				}]
			}
		}
	}]
}

Example 6 - Versioning

Here we push content for a specific major and minor version:

CODE
{
	"header": {
		"mode": "full",
        "major": "v4",
        "minor": "2234.92"
	},
	"segments": [{
		"key": "k22992",
		"texts": {
			"en": { "v": "Good day" },
			"fr": { "v": "Bonjour" },
			"de": { "v": "Guten Tag" }
		}
	}]
}


Example 7 - Explicitly delete segments

Placing delete on a segment will remove it from the flex document (for the given major/minor version).

Your JSON can, of course, contain any mix of updates, inserts, and deletions.


CODE
{
	"header": {
		"mode": "partial"
	},
	"segments": [
		{
			"key": "k22992",
			"delete": true
		},
		{
			"key": "k22993",
			"delete": true
		}
	]
}



JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.