thingweb / node-wot

Web of Things implementation on Node.js
27 stars 13 forks source link

Automatically http POST when adding a uriVariable #106

Closed MartinMeyer1 closed 3 years ago

MartinMeyer1 commented 3 years ago

Here is an action in my TD: "set_relay": { "description": "Turn on/off the relay", "safe": false, "idempotent": false, "uriVariables": { "state":{ "type": "integer", "minimum": 0, "maximum": 1 } }, "forms": [ { "href": "/relay{?state}", "op": "invokeaction", "contentType": "application/json", "htv:methodName": "GET" } ] }

When I run "thing.invokeAction("set_relay", undefined,{ 'uriVariables': { 'state': '0' }})" the consumer says : "[binding-http] HttpClient (invokeResource) sending POST to http://thing_ip/relay?state=0". But I want it to be a http GET, that's why I set "htv:methodName": "GET".

If I change the TD to : "set_relay": { "description": "Turn on/off the relay", "safe": false, "idempotent": false, "forms": [ { "href": "/relay", "op": "invokeaction", "contentType": "application/json", "htv:methodName": "GET" } ] } It says: [binding-http] HttpClient (invokeResource) sending GET to http://thing_ip/relay

So I think it is related to the fact that I use a uriVariable.

Or maybe I am doing something wrong?

danielpeintner commented 3 years ago

I think you are right, handleUriVariables() duplicates the form but does NOT copy over "htv:methodName"

see https://github.com/eclipse/thingweb.node-wot/blob/963a7537aa39de7d4af683b313bba96fe8ac1d6e/packages/core/src/consumed-thing.ts#L493

danielpeintner commented 3 years ago

Duplicate https://github.com/eclipse/thingweb.node-wot/issues/385

Note: this repo is out-dated and active development is done in https://github.com/eclipse/thingweb.node-wot/