Comments (7)
The issue is single vs double quotes in the request, not with python vs javascript. I can reproduce your results using curl
.
$ curl -H 'Content-Type: application/json' --data '{ "jsonrpc":"2.0", "method":"author_rotateKeys", "id":1 }' https://dev-node.substrate.dev:9933
{"jsonrpc":"2.0","result":"0xb2e193c900159b6cf86b2dedea550030c9c912a160e1996decbd09159527d92f882739012a3bb9803e7ee4ffd72a290436735dbdd20a463db2736365c112597b9a2eca667dedde4a32180b2c6bbecb033cc7640f0683da37f3b070c3f72abb2a","id":1}
$ curl -H 'Content-Type: application/json' --data "{ 'jsonrpc':'2.0', 'method':'author_rotateKeys', 'id':1 }" https://dev-node.substrate.dev:9933
{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error"},"id":null}
Standby and I'll dig deeper.
from substrate-node-template.
Thanks. So it's like this:
r = requests.post(url, data=json.dumps(payload), headers=headers)
I don't remember to have ever needed to do that, with any request call, ever. I have just looked up older code ... and found the difference. It was probably because I had always called it with json=payload
, i.e. this works too:
r = requests.post(url, json=payload, headers=headers)
Thank you very much. And sorry to have bothered you with this.
from substrate-node-template.
Looks like the tutorial that you are taking a look to could not have the latest changes. It is maintained by @shawntabrizi
link: https://www.shawntabrizi.com/substrate/querying-substrate-storage-via-rpc/
from substrate-node-template.
Have you tried by following the original tutorial?
I would suggest to try it on JavaScript and then see if you can replicate the issue.
from substrate-node-template.
I would suggest you try it out:
pip3 install requests
python3 substrate_RPC-flaw.py
I suppose, it comes from different stringification of dictionaries of JS vs Python??
The substrate RPC server should be language agnostic, and not force people to use JS, no?
Yes, this place HERE might be the wrong place. I guess it's the substrate core devs` job.
from substrate-node-template.
I can reproduce your results using curl.
Oh yes. Of course, that is even simpler. Well done.
It has to do with Python versus Javascript, because (while it's probably different for JS ??) ... the default way for Python to stringify its dictionaries seems to favor singlequotes '.
While the substrate RPC server is only happy with doublequotes " ??
from substrate-node-template.
The documentation for your preferred requests module explains what to do when the RPC you're calling needs valid JSON. https://requests.readthedocs.io/en/latest/user/quickstart/#more-complicated-post-requests (Third code snippet).
from substrate-node-template.
Related Issues (20)
- the trait `MaxEncodedLen` is not implemented for `std::vec::Vec<u32>` HOT 1
- Don't use default weights in the runtime HOT 2
- Multiple version conflict HOT 2
- failed to get frame-benchmarking as a dependency of package HOT 2
- failed to run custom build command for `tikv-jemalloc-sys v0.4.3+5.2.1-patched.2` HOT 1
- warning: "jemalloc support for `x86_64-pc-windows-msvc` is untested" error: failed to run custom build command for `tikv-jemalloc-sys v0.4.3+5.2.1-patched.2` HOT 12
- BUG: Build is failing for Ubuntu WSL in Windows 10 HOT 6
- build failed
- build failed
- build failed HOT 2
- Build error HOT 33
- ecryptfs => Filename to long HOT 1
- Docker image version to use on versions
- Fix broken FRAME link HOT 1
- Build error when trying to create a function that takes a `T::AccountId` along with `Origin`. HOT 1
- Add benchmarks to test runs HOT 1
- Close this repo to PRs HOT 5
- error: failed to start node HOT 7
- It's better to use an image sourced from paritytech dockerhub registry. And automate its' creation via CI.
- Missing `frame-weight-template.hbs` from file tree
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from substrate-node-template.