Running Webcore v0.3.10a
Im tearing my hair out (now bald ) trying to figure out how to make a HTTP Post Request work. Getting unauthorized (or other errors depending on the variations I have tried) . All of this done on my local LAN … basically I am trying to have Webcore send some data to another device REST API (a raspberry) that uses an API Key for access.
This curl works as expected:
curl -X POST "http://10.0.0.23:8080/rest/items/SomeString" -H "accept: */*" -H "Content-Type: text/plain" -u oh.smartthings.rPYLEXSp0wWkPpwTJJtl8mph8hNI8hEkWvlBpQ2opV5vlGqVyM5uw21lzdP8fEzgGlQgWzDiqC6EePuu49A:
So I wrote the most basic webcore script I could:
execute
Make a POST request to http://10.0.0.23:8080/rest/items/SomeString as type text/plain;
Log info “{$httpStatusCode}”;
Log info “{$httpContentType}”;
Log info “{$response}”;
end execute;
And here is the resulting response:
5/21/2021, 1:54:21 PM +223ms
+1ms â•”Received event [Elmwood].wc_async_reply = httpRequest with a delay of 0ms
+246ms â•‘Runtime (39565 bytes) successfully initialized in 84ms (v0.3.10a.20190223) (244ms)
+246ms â•‘â•”Execution stage started
+263ms â•‘â•‘401
+264ms â•‘â•‘Executed virtual command log (2ms)
+268ms â•‘â•‘application/json
+270ms â•‘â•‘Executed virtual command log (1ms)
+274ms â•‘â•‘{"error":{"message":"Authentication required","http-code":401}}
+275ms â•‘â•‘Executed virtual command log (1ms)
+278ms â•‘â•šExecution stage complete. (32ms)
+279ms â•šEvent processed successfully (279ms)
What could I be doing wrong here? Any guesses?