Search Results for

    Show / Hide Table of Contents

    Web trigger rule

    Introduction

    Web trigger rule is used to determine whether a new workflow should be triggered when Casewhere receives an HTTP request. You can learn more about web trigger here.

    Rule syntax

    Keywords

    You can use the following keywords to work with web trigger rules:

    Name Type Description
    @parameters IDictionary<string, string> Query string parameters.
    @headers IDictionary<string, IEnumerable> Header key-value pairs.
    @body DynamicDataObject A data object represents the request payload. You can access the attributes using the “dot” operator. For example, “@body.phoneNumber”.
    @apiFactory Factory object To construct Casewhere API objects. Read here for the full list of available Apis.

    Examples

    Example 1

    For the request “api/product?category_id=1” we can access the syntax below.

    @parameters["category_id"] == "1"
    

    Example 2

    Verify the Api Key in the request headers.

    #predicate
     
    // Parse the request header
    var dataApi = @apiFactory.Get<IDataApi>();
    
    if (!@headers.ContainsKey("Authorization"))
    {
        return new 
        {
            StatusCode = 400,
            Message = "Authorization header is missing"
        };
    }
     
    // Query Api Keys in DB
    var headerKey = @headers["Authorization"].First();
    var filter = FilterBuilder.Create().Eq("ApiKey", headerKey).Eq("Active", true).Build();
    var found = dataApi.Any("Applications", filter);
    
    if (!found)
    {
        return new 
        {
            StatusCode = 401,
            Message = "Invalid Api key"
        };
    }
    
    return true;
    
    In This Article
    Back to top Generated by DocFX