crossbario / crossbar

Crossbar.io - WAMP application router
https://crossbar.io/
Other
2.05k stars 274 forks source link

Crossbar Websocket server not accepting JSON POST data via cURL #1922

Closed petarmra closed 2 years ago

petarmra commented 2 years ago

I am trying to publish to my Crossbar.io Websocket server using the HTTP Bridge Publisher via win11 cmd curl. This is my command:

curl -H "Content-Type: application/json" -d '{"topic": "com.myapp.hello", "args": ["Hello, world"]}' http://192.168.64.1:8080/publish

my config.json

   "publish": {
        "type": "publisher",
        "realm": "realm1",
        "role": "anonymous"
                        }

This is the error I get:

curl: (6) Could not resolve host: com.myapp.hello,
curl: (6) Could not resolve host: args
curl: (3) [globbing] bad range in column 2
{"error":"Request body was invalid JSON.","args":[],"kwargs":{}}

I am not sure but maybe the instructions are outdated and my JSON format is not correct. Does anyone have experience with it?

oberstet commented 2 years ago

curl is confused by the " and ' in your terminal .. the likely bug: Windows 11. if you delete that and install a proper OS, it might work;)

petarmra commented 2 years ago

I don't that it's that. I tried outside of Win11 as well and everywhere I get errors pertaining to the JSON format. For instance here: https://reqbin.com/curl

Do you perhaps have a working curl publish command which works on your side?

oberstet commented 2 years ago

the errors are coming from curl command line parsing, it fails to parse your command line in your (windows) terminal

but here is an old example: https://github.com/crossbario/crossbar-examples/tree/master/rest/caller , which I dug out using find ~/scm/crossbario/crossbar-examples/ -name "Makefile" -exec grep -Hi "curl" {} \; ..