Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

401 when calling a contract's function #159

Closed
dgaviola opened this issue Nov 13, 2018 · 3 comments
Closed

401 when calling a contract's function #159

dgaviola opened this issue Nov 13, 2018 · 3 comments

Comments

@dgaviola
Copy link

dgaviola commented Nov 13, 2018

I'm trying to execute a function in a test contract:

curl -X POST \
  https://ropsten.infura.io/v3/api-key/ \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'postman-token: de6e8143-53c2-ae67-7523-a023adfea4eb' \
  -d '{"id":1542118207867,"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0xb0c55094816978a74bd972a03e84894d6787b4a6","data":"0x17d7de7c"},"latest"]}'

However I'm getting a 401 error. I tried adding the contract in Infura's dashboard, but that didn't help. Also tried to use basic HTTP auth with the API key and secret, but didn't work either.

@dgaviola
Copy link
Author

dgaviola commented Nov 13, 2018

I just removed the v3 in the URL and it started to work. I think it is a bit confusing that the dashboards gives you a URL that does not work and the docs points you to a different URL.

Also, some methods work when using v3, for example eth_blockNumber, which makes it more confusing.

@dgaviola
Copy link
Author

dgaviola commented Nov 13, 2018

After more debugging, it seems like my problem was a trailing / in the URL. Removing it fixed the issue, even when using v3.

I guess it would be nice to handle that case.

@ryanschneider
Copy link

Sorry for the confusion, we are actively updating the documentation to make v3 usage more clear, we hope for the changes to go live soon.

As you found, it was the trailing slash that caused the issue, I'll see if we can support that, or at least provide a better error message.

@INFURA INFURA locked as resolved and limited conversation to collaborators Nov 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants