Skip to main content

Use the test a connection function in Sitecore CDP REST API

Abstract

How to test a connection in Sitecore CDP (Data model 2.1).

You can use the Connections REST API to perform the test a connection function by sending a context payload to Sitecore CDP.

To test a connection in Sitecore CDP, use the following:

POST: https://apiEndpoint/v2/connections/testWebService

{  
   "webService":{  
      "name":"Destination 2",
      "description":"Second",
      "modifiedByUserRef":"2a45ba95-208b-451a-8c72-489a25d52913",
      "modifiedAt":"2018-09-07T08:47:20.489Z",
      "revision":1,
      "archived":false,
      "auth":{  
         "authType":"none"
      },
      "request":{  
         "requestType":"post",
         "webServiceUrl":"https://silent-cloud-2479.getsandbox.com/cityinfo",
         "requestBody":"{\n  \"city0\": \"London\",\n  \"season0\": \"winter\",\n  \"city1\": \"Edinburgh\",\n  \"season1\": \"winter\"\n}"
      },
      "exampleValue":"{\"city0\":\"London\",\"season0\":\"winter\",\"city1\":\"Edinburgh\",\"season1\":\"winter\"}",
      "inputMappings":[  

      ],
      "outputMappings":[  

      ],
      "customHeaders":[  
         {  
            "externalWebServiceRef":"25bc4f8d-afcb-4f36-8fb5-14021a1efe28",
            "name":"Accept",
            "value":"application/json"
         },
         {  
            "externalWebServiceRef":"25bc4f8d-afcb-4f36-8fb5-14021a1efe28",
            "name":"Accept-Encoding",
            "value":"gzip"
         },
         {  
            "externalWebServiceRef":"25bc4f8d-afcb-4f36-8fb5-14021a1efe28",
            "name":"Content-Type",
            "value":"application/json"
         }
      ],
      "systemType":"DESTINATION",
      "connectionTimeout":1000,
      "socketTimeout":1000,
      "icon":"assets/images/channel-images/sms.svg"
   },
   "webServiceContext":{  

   }
}

The following is a 200 response:

{
    "statusCode": 200,
    "executionTimeInMilliseconds": 307,
    "request": "{\n  \"city0\": \"London\",\n  \"season0\": \"winter\",\n  \"city1\": \"Edinburgh\",\n  \"season1\": \"winter\"\n}",
    "response": {
        "item0": {
            "topAttraction": "Tower of London",
            "weather": {
                "overall": "snow",
                "averageTemperature": 4
            }
        },
        "item1": {
            "topAttraction": "Edinburgh Castle",
            "weather": {
                "overall": "snow",
                "averageTemperature": 4
            }
        }
    },
    "mappingResult": {
        "item0": {
            "topAttraction": "Tower of London",
            "weather": {
                "overall": "snow",
                "averageTemperature": 4
            }
        },
        "item1": {
            "topAttraction": "Edinburgh Castle",
            "weather": {
                "overall": "snow",
                "averageTemperature": 4
            }
        }
    }
}