WebHooks - JSON

Have more questions? Submit a request
Image_4-14-23_at_2.51_PM.jpeg

This article was developed to describe the use of Webhooks and JSON within Centrex CRM.

Overview

JSON stands for JavaScript Object Notation. This is an open-stranded file format that uses human-readable text to transmit data objects consisting of key-value pairs and array data types. It is easy for machines to parse and generate but also easy for humans to read and write.

JSON is built on two structures:

    • A collection of key/value pairs (object)
    • An ordered list of values (array)

JSON is a text format that is completely independent but uses conventions that are familiar to programmers of the C family of languages. (ex. C++, JavaScript, Python, etc.)

Here is a link to learn more about JSON: https://www.w3schools.com/whatis/whatis_json.asp

 

1. Enter the JSON Endpoint/Url in the WebHook URL* field 

This is the same step you would do for a traditional Key Value Pair post. (see above)

This URL/Endpoint will be provided by the receiving end in the posting instructions or sample string provided.

JSON_1.jpg


2. Add Headers and their Value in the Headers section

These should be given to you in the posting instructions from the receiving party.  Each post expects different items to be passed in the header. You can have as many headers as needed/required by the receiving party.

An example of a JSON header would be:

Header = contentType               Value = application/json

The Content-Type entity header is used to indicate the media type of the resource. In responses, it tells you what the content type of the returned content actually is.

Please gather this information from your receiving party or the posting instructions provided.

JSON_2.jpg



3. JSON Body

Select the JSON Request Type to add a JSON Body to the WebHook.

JSON_3.jpg

Once that is selected, the JSON Body section appears. This is where you can build out the JSON body for the webHook post.

JSON data is written as a key/value pair. A key/value pair contains a key name (in double quotes), followed by a colon, and then followed by the value (in double quotes). The key name will be given to you by the receiving party and the value will be the system field/custom field that is set up in the CRM.

Example: “first_name” : “{FIRSTNAME}”,

When adding more than one value, you will separate each row by a comma. Then you will wrap your JSON values in brackets to open and close the container.

Example:

{

“first_name” : “{FIRSTNAME}”,

“last_name” : “{LASTNAME}”

}

If you want to add multiple fields to be passed to ONE field on the receivers' end, you can add containers within the main JSON container. For example, if you want the fields of {ADDRESS}, {ADDRESS2} {CITY} {STATE} and {ZIP} to all be passed to ONE address field on the receivers end, you will set up the JSON container like the one below. This will tell the post to add those fields together to one field instead of 5 individual fields.

Example:

                        {

    "first_name": "{FIRSTNAME}",

    "last_name": "{LASTNAME}",

    "address": {

        "street": "{ADDRESS}",

        "street2": "{ADDRESS2}",

        "city": "{CITY}",

        "state": "{STATE}",

        "zip": "{ZIP}"

    }

}

Add the required fields stated in the posting instructions to the JSON Body in the format above. Once this is completed, you can click on the “Format JSON” button to rearrange the JSON Body to the correct format. THEN CLICK SAVE WEBHOOK.

JSON_3b.jpg

Please double-check the posting instructions given to make sure you have set up the headers and JSON body correctly.  You can then test the webHook on a test contact. If everything is set up correctly, you should get a “Success” result under the WebHook Results on the right-hand side of the WebHook page.

 

Articles in this section

Was this article helpful?
0 out of 0 found this helpful
Share