ankraft / ACME-oneM2M-CSE

An open source CSE Middleware for Education.
https://acmecse.net/
BSD 3-Clause "New" or "Revised" License
23 stars 16 forks source link

Discovery #139

Open gghabri opened 6 months ago

gghabri commented 6 months ago

Hello,

I'm attempting to discover resources based on labels.

I'm running ACME as an in-cse and executing the following command in the terminal:

curl -X GET -H 'X-M2M-Origin:Cmysensor' -H 'X-M2M-RI:123' -H 'X-M2M-RVI:3' -H 'Content-Type:application/json' -H 'Accept:application/json' http://localhost:8080/cse-in/MySensor/Container?fu=2&lbl=tag:temperature&rcn=8

However, I'm receiving the representation of the Container resource in the response body instead of the representation of the resource containing 'tag:temperature' as the label attribute value.

When I execute the request using the RESTClient provided by the ACME web interface, I get the expected result.

Could you please explain why it's not working with the terminal?

Best regards,

ankraft commented 6 months ago

Your request with the rcn request parameter with value "8" (child resources) is targeted at the container, but it should only produces a stub representation of the container, like this, if there are no further child resources in the result.

{"m2m:cnt": {}}

There is no further content because this rcn doesn't include any attributes of the target resource (only for child resources). If you change the rcn to, for example "4" (attributes and child resources), it would include the container's attributes.

I am not sure what the difference is with the WebUI, though.

Another point: I would use quotes for the URL as well in your curl request, otherwise a shell interprets the special characters in a URL, especially "&"...