Because your payload contains quote marks, you have to try a bit harder to get that passed to the http action. The rules interpreter is looking at those quotemarks, and treating them like it does any other quotemark. “Ooh, a string that starts here and stops there.”
rule "testcase"
when
Item test received update ON
then
var url = "http://172.21.10.182/devices/1010013"
var contenttype = "application/json"
var POSTrequest = '{“name”: “GOTO_POS_CMD”, “value”: 20}'
var output = sendHttpPostRequest(url, contenttype, POSTrequest)
end
rule "testcase"
when
Item test received update ON
then
var url = "http://172.21.10.182/devices/1010013"
var contenttype = "application/json"
var PUTrequest = '{"name": "GOTO_POS_CMD", "value": 20}'
var output = sendHttpPutRequest(url, contenttype, PUTrequest)
end
2020-01-24 11:02:26.741 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home2.sitemap' has errors, therefore ignoring it: [2,2]: required (...)+ loop did not match anything at input 'switch'
2020-01-24 11:02:44.822 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home2.items'
2020-01-24 11:02:53.767 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home2.sitemap' has errors, therefore ignoring it: [2,2]: required (...)+ loop did not match anything at input 'switch'
2020-01-24 11:02:58.508 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home2.sitemap' has errors, therefore ignoring it: [2,2]: required (...)+ loop did not match anything at input 'switch'
2020-01-24 11:04:19.930 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home.sitemap' has errors, therefore ignoring it: [44,1]: no viable alternative at input 'switch'
2020-01-24 11:04:50.326 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.sitemap'
2020-01-24 11:05:26.350 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home.sitemap'
2020-01-24 11:05:33.630 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home2.sitemap'
2020-01-24 13:45:15.957 [WARN ] [.core.internal.folder.FolderObserver] - Error while opening file during update: C:\openHAB\conf\rules\testcase.rules
2020-01-24 13:45:16.342 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'testcase.rules'
2020-01-24 13:45:16.342 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'testcase.rules' is either empty or cannot be parsed correctly!
2020-01-24 13:45:17.584 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'testcase.rules' has errors, therefore ignoring it: [1,6]: no viable alternative at input 'â'
It means it doesn’t like the content of your rules file.
Given the funny character, you probably need to look into the character encoding your editor uses when it saves a file.
rule “testcase”
when
Item test received update ON
then
var url = "http://172.21.10.182/devices/1010013"
var contenttype = "application/json"
var PUTrequest = '{"name": "GOTO_POS_CMD", "value": 20}'
var output = sendHttpPutRequest(url, contenttype, PUTrequest)
end