webCoRE Update v0.3.10f.20190822 - Custom headers on web requests by @Bloodtick_Jones, capability selection fix


#1

The v0.3.10f.20190822 update includes a feature developed by @Bloodtick_Jones to allow sending ad-hoc HTTP headers along with local and remote web requests. Previously only the Authorization and Content-Type headers were supported. See the original discussion here:

To use custom headers, set the Authorization Header field to a JSON object. Both the Value and Expression inputs work for typing in JSON, but I prefer the Expression editor since you can format on multiple lines:

'\{
    "Header-A": "anteater",
    "Header-B": "bumblebee"
\}'

Note that the { and } must be escaped with a backslash to avoid confusing the webCoRE expression parser. Both Value and Expression require this escaping, but as usual Value does not require the enclosing single quotes.

The expression used here must resolve to text with valid JSON encoding. Use the json() function to properly encode values that may contain a double quote character. The json function is also useful for safely encoding data from a variable. In the Expression input:

'\{
    "x-foo": {json('a"b')}
\}'

The String list (text) variable type can also be used for these headers, provided that the piston always sends the same set of headers since you cannot remove a key once it has been added to a list. Use the Set Variable action and provide the header name in list index. Then simply use the expression json(myHeaderList) with your string list variable in the Authorization Header field. This approach automatically outputs the {} braces and encodes values properly.

Device selection by capability

This release also splits the list of capabilities in the webCoRE smart app into three pages. This addresses issues that some users were having with selecting devices that did not appear in the actuators and sensors lists. With a large number of devices, the SmartThings platform could timed out while loading the capabilities list page, so it has been divided alphabetically into three pages.


Make a Web Request - Custom Header?
Extract data from Airly app with URL GET method
How do I code an HTTPS request with header data
Web requests may fail with 406 status code due to incorrect Accept header
Making a web request failing
pinned globally #2

split this topic #3

2 posts were merged into an existing topic: Conditions evaluating incorrectly


#5

Can someone please move the above 2 posts to the following? I seem to be having the same issue as this post.


#6

Forgive me for being completely uninformed but so if I’m trying to use two headers - one named “Access-Token” and another named “Content-Type” I should do the following?

UPDATE: Yup guess that’s how it works becUse I got it working. Thanks for your help.