Home > Software design >  Generating a Session Key in Windows 10
Generating a Session Key in Windows 10

Time:03-19

I am a noob at all this and I am trying to run a Linux curl command in Windows 10 to generate session key. The following is the command in Linux.

curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys"}' http://localhost:9933/ 

When I run the command at the Windows command prompt I am receiving the following error.

E:\>curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys"}' http://localhost:9933/
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 18:
author_rotateKeys}'
                 ^

E:\>

Any idea how would I covert the command to work with Windows 10? I just need to generate a key for a node I need to connect to from a Windows box.

CodePudding user response:

If you don't have WSL2 setup (useful if you ever need other *nix tools) where that command will just work as is, or don't want to use PowerShell where

curl.exe -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys"}' http://localhost:9933/

works (notice the curl is replaced with curl.exe, because in PowerShell 5.1 curl is just an alias for Invoke-WebRequest, it's removed in PowerShell 6 and later, but they're not built-in and won't replace PowerShell 5.1 when installed), then on Command Prompt replace single quote with double quote, and for double quote inside them, escape it (replace it with \")

curl -H "Content-Type: application/json" -d "{\"id\":1, \"jsonrpc\":\"2.0\", \"method\": \"author_rotateKeys\"}" http://localhost:9933/
  • Related