fullphat / snarl

When { stuff_happens(); tell_me() }
http://snarl.fullphat.net
57 stars 2 forks source link

Endpoint ' {variable]' not recognized #87

Open iMelsom opened 4 years ago

iMelsom commented 4 years ago

Hi When trying to use WebSNP / Oxide WebSNP v1 responds correctly, but v2 stubbornly refuse to work. Sending the test message http://{ip-address}/v1 gives the expected reply Sending the test message http://{ip-address}/v2 gives an empty reply I have tried both the LAN Ipaddress (192.168.2.10) and "localhost" for {ip-address} For port number I have tried 8080. 8084, and 23053 (I know 23053 is the GNTP port, but since I am scripting to replace a PHP-GNTP script that din't survive upgrade to PHP7.4, the easiest route is to reuse allready open firewall rules)

I get the following errors in reply when I add /apps or /registrations:

C:\Snarl 5.1>curl -H "Content-Type: application/json" "http://localhost:8080/v2/registrations" -d "{ \"app-id\": \"foo.bar\", \"title\": \"Foo.Bar\" }"
{
  "Content": null,
  "Succeeded": false,
  "StatusCode": 215,
  "StatusText": "NotFound",
  "Message": "Endpoint 'registrations' not recognised"
}
C:\Snarl 5.1>curl -H "Content-Type: application/json" "http://localhost:8080/v2/registrations" -d "{ \"app-id\": \"foo.bar\", \"title\": \"Foo.Bar\" }"
{
  "Content": null,
  "Succeeded": false,
  "StatusCode": 215,
  "StatusText": "NotFound",
  "Message": "Endpoint 'registrations' not recognised"
}

snarl --log shows this:


[2020-03-30 11:32:00.252] AsyncTcpServer.acceptCallback(): new connection from 127.0.0.1:52655
[2020-03-30 11:32:00.262] HTTPRequest.HTTPRequest(): requestLine="POST /v2/apps HTTP/1.1"
[2020-03-30 11:32:00.262] [snphttp] server_OnRequestReceived(): uri="/v2/apps"
[2020-03-30 11:32:00.262] [snphttp] server_OnRequestReceived(): body="{ "app-id": "foo.bar", "title": "Foo.Bar" }"
[2020-03-30 11:32:00.262] [snphttp] V2 request!
[2020-03-30 11:32:00.262] * method: "POST"
[2020-03-30 11:32:00.262] * uri: "/v2/apps"
[2020-03-30 11:32:00.262] * body: "{ "app-id": "foo.bar", "title": "Foo.Bar" }"
[2020-03-30 11:32:00.262] + apps
[2020-03-30 11:32:00.262] count:1

[2020-03-30 11:32:16.089] AsyncTcpServer.acceptCallback(): new connection from 127.0.0.1:52657
[2020-03-30 11:32:16.099] HTTPRequest.HTTPRequest(): requestLine="POST /v2/registrations HTTP/1.1"
[2020-03-30 11:32:16.099] [snphttp] server_OnRequestReceived(): uri="/v2/registrations"
[2020-03-30 11:32:16.099] [snphttp] server_OnRequestReceived(): body="{ "app-id": "foo.bar", "title": "Foo.Bar" }"
[2020-03-30 11:32:16.099] [snphttp] V2 request!
[2020-03-30 11:32:16.099] * method: "POST"
[2020-03-30 11:32:16.099] * uri: "/v2/registrations"
[2020-03-30 11:32:16.099] * body: "{ "app-id": "foo.bar", "title": "Foo.Bar" }"
[2020-03-30 11:32:16.099] + registrations
[2020-03-30 11:32:16.099] count:1
iMelsom commented 4 years ago

Logfile attached

snarl-5-1.debug.log

fullphat commented 4 years ago

WebSNP V2 doesn't work properly in Beta 4. Apologies - I ripped a lot of the transports right back to basics as it was all getting a bit messy. I think the win32ipc transport supports everything now, right back to really old versions of the Snarl API.

As for WebSNP, I think Beta 4 has V0 and V1 complete and working, but V2 isn't there.

As a test, GET /v2/infoshould work, but very little else will right now.

iMelsom commented 4 years ago

Ah. I see. That explains my problems :D

Thank you for the update! :)

fullphat commented 4 years ago

Quick update. I've re-implemented /v2/registrations so, in the next beta, the following will work:

curl -H "Content-Type: application/json" "http://localhost:8080/v2/registrations" -d "{ \"appid\": \"foo.bar\", \"name\": \"Foo.Bar\" }

Note the parameter name changes for app-id (appid) and title (name) however.

fullphat commented 4 years ago

This is possible too 😁

curl -H "Content-Type: application/json" "http://localhost:8084/v2/registrations" -d "{ \"appid\": \"foo.bar\", \"name\": \"Foo.Bar\", \"version\": \"23\", \"icons\": { \"stock\": \"misc-hotdog\" }, \"events\": [ { \"id\": \"1\", \"name\": \"one\" }, { \"id\": \"2\", \"name\": \"two\", \"enabled\": false } ] }"