Discussions

Expand all | Collapse all

Escaping a single quote in WebHook JSON

  • 1.  Escaping a single quote in WebHook JSON

    Posted 14 days ago
    I have a Web Hook that is sending JSON data to an end point external to Quickbase. If I embed an escaped single quote in one of the fields it works fine:
    {
    "ComplaintSummary" : "This works fine with the single \'quotes \' escaped"
    }

    When I use a Formula-Text field to insert the escape characters with the SearchAndReplace function, the web hook fails. The Formula-Text field result is the same as above. As far as I've been able to tell, QB never sends the data.

    Thanks in advance for any assistance.



    ------------------------------
    Rick Putnam
    ------------------------------


  • 2.  RE: Escaping a single quote in WebHook JSON

    Posted 14 days ago
    I was able to sort this out by creating the Formula-Text field as follows:

    // single quotes and double quotes must be "escaped" so they don't interfere with the JSON data formatting
    var Text DOUBLEQUOTE = "\"";
    var Text SINGLEQUOTE = "'";
    var Text ESCAPEDSINGLEQUOTE = "\\'";
    var Text ESCAPEDDOUBLEQUOTE = "\\\"";
    var Text ENCODEDFORSINGLEQUOTE = SearchAndReplace([Complaint Summary], $SINGLEQUOTE, $ESCAPEDSINGLEQUOTE);
    SearchAndReplace($ENCODEDFORSINGLEQUOTE, $DOUBLEQUOTE, $ESCAPEDDOUBLEQUOTE)

    Now, the web hook is able to transmit data with any pattern of inline single or double quotes.

    ------------------------------
    Rick Putnam
    ------------------------------



  • 3.  RE: Escaping a single quote in WebHook JSON

    Posted 14 days ago
    Thx for Posting!

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------