My first data call fails

this is straight from the example posted for data plugin. it does not work using curl. what am i missing?

C:\Users\murth>curl  http://localhost:41184/notes?token=f7dc220a450f7af904e4e4c02336f4310a287fa392eb3652f5cd45768fe86ae50976411d5994760a7fe9a1c0c94a9843d58b03d12f8e4c21df712934055832bf --data '{ "title": "My note", "body": "Some note in **Markdown**"}'
{"error":"Internal Server Error: Unexpected token ' in JSON at position 0: \n\nSyntaxError: Unexpected token ' in JSON at position 0\n    at JSON.parse (<anonymous>)\n    at Object.<anonymous> (C:\\Users\\murth\\AppData\\Local\\Programs\\Joplin\\resources\\app.asar\\node_modules\\@joplin\\lib\\services\\rest\\routes\\notes.js:348:38)\n    at Generator.next (<anonymous>)\n    at C:\\Users\\murth\\AppData\\Local\\Programs\\Joplin\\resources\\app.asar\\node_modules\\@joplin\\lib\\services\\rest\\routes\\notes.js:8:71\n    at new Promise (<anonymous>)\n    at __awaiter (C:\\Users\\murth\\AppData\\Local\\Programs\\Joplin\\resources\\app.asar\\node_modules\\@joplin\\lib\\services\\rest\\routes\\notes.js:4:12)\n    at Object.default_1 [as fn] (C:\\Users\\murth\\AppData\\Local\\Programs\\Joplin\\resources\\app.asar\\node_modules\\@joplin\\lib\\services\\rest\\routes\\notes.js:324:12)\n    at Api.<anonymous> (C:\\Users\\murth\\AppData\\Local\\Programs\\Joplin\\resources\\app.asar\\node_modules\\@joplin\\lib\\services\\rest\\Api.js:155:41)\n    at Generator.next (<anonymous>)\n    at C:\\Users\\murth\\AppData\\Local\\Programs\\Joplin\\resources\\app.asar\\node_modules\\@joplin\\lib\\services\\rest\\Api.js:8:71"}curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) unmatched close brace/bracket in URL position 26:
Some note in **Markdown**}'
                         ^

Looks like an issue between the windows version of curl and curl on other systems. A quick search online says that you might need to wrap the url with double quotes (").

I think you might have to do the same for the JSON, but I'm not sure how easy that will be.
FYI, I copied the curl command above and it runs fine on Ubuntu, so this is certainly due to the windows curl implementation.

Curl is an alias to Invoke-WebRequest (a Powershell function), if you want curl as it is on other platforms, you need to specifically call it as curl.exe

2 Likes

Or you can run it from within WSL, which might be better if you plan to run commands you've found on the net more often.