Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
titleAvailability

This routine is available starting with SIL Engine™ 4.1.5.

Syntax

fromJsongetWebhookPayload(json)

Description

Excerpt

Converts the given JSON string into a SIL™ type (can be a primitive, array or struct).

Parameters

...

Parameter name

...

Type

...

Required

...

Description

...

json

...

string

...

Yes

...

The JSON to be converted.

Return type

variable return type - depending on the left hand side operator type

Examples

...

Gets the Webhook payload from the calling client.


Return type

WebhookPayload

Examples

Example 1 - Getting the Webhooks payload from the calling client

Code Block
languagecpp
themeEclipse
firstline16
linenumberstrue
struct//getting codethe {REST/HTTP call input parameters:
WebhookPayload numberhttpRequestPayload [] rgba= getWebhookPayload();

//getting the used stringHTTP hex;method:
}string httpMethod struct color {
    string color;
    string category;
    string type;
    code code;
}

struct colors {
    color [] colors;
}

Example 1 - Reading JSON from a file

Code Block
languagecpp
themeEclipse
firstline16
linenumberstrue
string json = readFromTextFile("C:\\colors.json");


colors cData;
cData = fromJson(json);

return cData.colors[0].color;

Example 2 - Reading JSON from a variable

Code Block
languagecpp
themeEclipse
firstline16
linenumberstrue
string json = "{\"colors\":[{\"color\":\"red\",\"category\":\"hue\",\"type\":\"primary\",\"code\":{\"rgba\":[255,0,0,1],\"hex\":\"#FF0\"}}]}";

colors cData;
cData = fromJson(json);

return cData.colors[0].color= httpRequestPayload.httpMethod;//This can be something like "GET", "POST", "PUT" etc.

//getting the http request payload (body):
string httpPayload = httpRequestPayload.payload;

//getting the http query parameters:
WebhookParam[] httpQueryParams = httpRequestPayload.queryParams;
string firstQueryParamName = httpQueryParams[0].name;
string firstQueryParamValue = httpQueryParams[0].values[0];

//sending the response back to the caller:
appendToWebhookResponse("http method:");
appendToWebhookResponse(httpMethod);
appendToWebhookResponse("payload:");
appendToWebhookResponse(httpPayload);
appendToWebhookResponse("firstQueryParamName:");
appendToWebhookResponse(firstQueryParamName);
appendToWebhookResponse("firstQueryParamValue:");
appendToWebhookResponse(firstQueryParamValue);

//returning a custom HTTP status code:
return true, 1234;


See also

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
cqllabel = "http_supportappendToWebhookResponse"
labelsjira_project_routine

...