Monero - Json RPC - Method not found - methods

Hey there i am using the most recent command line tools from monero:
monerod:
Monero 'Lithium Luna' (v0.12.3.0-release)
Started using: ./monerod
Running on: 127.0.0.1:18081
monero-wallet-rpc:
Monero 'Lithium Luna' (v0.12.3.0-release)
Started using: ./monero-wallet-rpc --wallet-dir /path/to/wallets/ --rpc-bind-port 28081 --disable-rpc-login
Running on: 127.0.0.1:28081
I am currently testing rpc calls from:
https://getmonero.org/resources/developer-guides/wallet-rpc.html
Most of them work, but there are many rpc calls which seem not working...
For example:
curl -X POST http://localhost:28081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"refresh"}' -H 'Content-Type: application/json'
Returns:
{
"error": {
"code": -32601,
"message": "Method not found"
},
"id": "0",
"jsonrpc": "2.0"
}
Can anyone refer to this?
I am using the most recent versions and the documentation is also up to date.
Thanks and Greetings!

Try this command with the params option in the json.
curl -X POST http://localhost:28081/json_rpc \
-d '{"jsonrpc":"2.0","id":"0","method":"refresh","params":{"start_height":100000}}' \
-H 'Content-Type: application/json'

The problem is that you're using an --rpc-bind-port equivalent to that of the testnet wallet RPC port. Try using another value like 40000 and curl to that instead.
The relevant ports are here under the namespace 'config':
https://github.com/monero-project/monero/blob/master/src/cryptonote_config.h

Related

Duckling send JSON to parse method ('Need a 'text' parameter to parse' error)

I work with Duckling, whish works on my local machine on port 8000. via CURL. Requests of the following type:
curl -X POST https://0.0.0.0:8000/parse -d 'locale=en_GB&text=tomorrow at eight'
executed successfully.
But when I do so:
curl -X POST https://0.0.0.0:8000/parse -H 'Content-Type: application/json' -d '{"locale": "en_GB", "text": "tomorrow at eight"}'
The HTTP 422 code is returned with the message "Need a 'text' parameter to parse".
How to correctly pass JSON to Duckling?

Send data to API containing special characters

I am trying to send JSON data containing a mac address to an api using this command:
$value={ "pcModel": "KAT12", "displayType": "DELL U2311H", "graphicsType": "Microsoft Remote Display Adapter", "displayServiceTag": "HV8XP08Q079L", "ipAddress": "172.16.4.194", "recDate": "2022-10-06 16:57:55", "serviceTag": "18LQ9X1;Diskwear:(4.91TBW ; 15393 Hours)", "wolMode": "lanwithpxeboot;CC:101010-0118ZH;os:Ubuntu", "sleepState": "disable", "macAddress": "90:B1:1C:8E:D5:11", "hostName": "CI-KR95-05", "diskMode": "raid", "diskType": "Samsung SSD 850 PRO 512GB;TBW+Hrs:(4.91TB;15393 HrH) ;Clock:3.4GHz;Max Clock:3.67GHz(108%);RAM:32GB" }
curl -X "PUT" -H "Accept: application/json" -H "Authorization: Token 62d85330rf562c4cd6c1fb1a64d1" -d "$value" --url "https://my_api.org/api/inventory/84:2b:2b:a0:0s2:18
but I get the following answer:
user#ubuntu:~$ curl -X "PUT" -H "Accept: application/json" -H "Authorization: Token 62d85df90210cd1a827bc1518c4cd6c1fb1a64d1" -d "$value" --url "https:/my_api/api/inventory/84:2b:2b:a0:0s2:18"
curl: (3) URL using bad/illegal format or missing URL
I tried to escape the ":" colon characters with \ like this
curl -X "PUT" -H "Accept: application/json" -H "Authorization: Token 62d85330rf562c4cd6c1fb1a64d1" -d "$value" --url "https://my_api.org/api/inventory/84\:2b\:2b\:a0\:0s\:18"
but I get no output and it sends nothing.
any Idea how to send this data without having the bad format error?
Thanks a lot
I removed the "?" from $value and added single quotes.
Try this:
#!/bin/bash
value='{ "pcModel": "KAT12", "displayType": "DELL U2311H", "graphicsType": "Microsoft Remote Display Adapter", "displayServiceTag": "HV8XP08Q079L", "ipAddress": "172.16.4.194", "recDate": "2022-10-06 16:57:55", "serviceTag": "18LQ9X1;Diskwear:(4.91TBW ; 15393 Hours)", "wolMode": "lanwithpxeboot;CC:101010-0118ZH;os:Ubuntu", "sleepState": "disable", "macAddress": "90:B1:1C:8E:D5:11", "hostName": "CI-KR95-05", "diskMode": "raid", "diskType": "Samsung SSD 850 PRO 512GB;TBW+Hrs:(4.91TB;15393 HrH) ;Clock:3.4GHz;Max Clock:3.67GHz(108%);RAM:32GB" }'
curl -X "PUT" -H "Accept: application/json" -H "Authorization: Token 62d85330rf562c4cd6c1fb1a64d1" -d "$value" --url "https://my_api.org/api/inventory/84:2b:2b:a0:0s2:18"
Didn't your mother teach you how to format?
value='{
"pcModel": "KAT12",
"displayType": "DELL U2311H",
"graphicsType": "Microsoft Remote Display Adapter",
"displayServiceTag": "HV8XP08Q079L",
"ipAddress": "172.16.4.194",
"recDate": "2022-10-06 16:57:55",
"serviceTag": "18LQ9X1;Diskwear:(4.91TBW ; 15393 Hours)",
"wolMode": "lanwithpxeboot;CC:101010-0118ZH;os:Ubuntu",
"sleepState": "disable",
"macAddress": "90:B1:1C:8E:D5:11",
"hostName": "CI-KR95-05",
"diskMode": "raid",
"diskType": "Samsung SSD 850 PRO 512GB;TBW+Hrs:(4.91TB;15393 HrH) ;Clock:3.4GHz;Max Clock:3.67GHz(108%);RAM:32GB"
}'
$value is not a legal variable name in bash for declaration, only when you want to look it up. use value=
Also, you are missing a " after the URL.
$ curl "http:/cake.com/nom-nom
> "
curl: (3) URL using bad/illegal format or missing URL
The protocol schema is followed by colon-slash-slash ://. so you need one more:
https://
Maybe you want to read the URL rfc:
https://www.ietf.org/rfc/rfc2718.txt
2.1.2 Improper use of "//" following ":"
Contrary to some examples set in past years, the use of double
slashes as the first component of the of a URL
is not simply an artistic indicator that what follows is a URL:
Double slashes are used ONLY when the syntax of the URL's contains a hierarchical structure as described in RFC
2396. In URLs from such schemes, the use of double slashes indicates that what follows is the top hierarchical element for a
naming authority. (See section 3 of RFC 2396 for more details.)
URL schemes which do not contain a conformant hierarchical
structure in their should not use double
slashes following the ":" string.
Thanks for your answers.
I found the reasons why my code was not updating the API
1 - I needed to specify the "Content-Type: "application/json" parameter to tell the API that the data sent hat JSON format otherwise I saw in verbose mode that the data has a "x-www-form-urlencoded" format that the API can't understand.
2 - The data sent with curl must accept a value with the format like this
value='{
"pcModel": "KAT12",
"displayType": "DELL U2311H",
"diskType": "Samsung SSD .."
}'
3 - The curl request must be sent with double quotes around the url and the data ""
So the end request looks like this:
curl -k -X "PUT" -H "Content-Type: application/json"\
-H "Accept: application/json" -H "Authorization: Token 62d85df902101828g84kc4cd6c1fb1a64d1" \
--url "https://my_api.org/api/inventory/84:2b:2b:a0:0s2:18" \
-d "$value"

Using Curl to pull down Call Log Data

I want to pull down call data from RingCentral using a shell script and curl. I'm then going to put that into ELK to build a dashboard using Kibana. However, I don't know what I'm doing with the API. Does anyone have a place for me to start or some sample code to do this?
I'm currently struggling with just using curl to authenticate to get a token. At the moment I keep getting unsupported grant type. I setup the application in Sandbox and a "Server Only No UI".
I have run this from a Centos 7 box using a bash shell.
Here is the code have tried:
curl -X POST "https://platform.devtest.ringcentral.com/restapi/oauth/token"; \
-H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "my client id:my client secret" \
-d "username=username&password=password&extension=<extension>&grant_type=password"
I left the username and password blank because I wasn't sure what that was.
The output is as follows:
{
"error" : "invalid_request",
"error_description" : "Unsupported grant type",
"errors" : [ {
"errorCode" : "OAU-250",
"message" : "Unsupported grant type"
} ]
}./rctest1.sh: line 2: -H: command not found
I've been able to reproduce your error and can resolve it by removing the semi-colon (;) after the URL in your command.
Explanation
A semi-colon creates two separate CLI commands instead of one, so in your call, you have two requests.
- Your Request 1
$ curl -X POST "https://platform.devtest.ringcentral.com/restapi/oauth/token"
- Your Request 2
$ -H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "my client id:my client secret" \
-d "username=username&password=password&extension=&grant_type=password"
- Your Response 1
{
"error" : "invalid_request",
"error_description" : "Unsupported grant type",
"errors" : [ {
"errorCode" : "OAU-250",
"message" : "Unsupported grant type"
} ]
}
- Your Response 2
./rctest1.sh: line 2: -H: command not found
- Test Command
Here's a simple test showing the OS trying to process two commands:
$ hello;world
-bash: hello: command not found
-bash: world: command not found
Solution
- Working Request
Here is a working request without the semi-colon:
$ curl -X POST "https://platform.devtest.ringcentral.com/restapi/oauth/token" \
-H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "my client id:my client secret" \
-d "username=username&password=password&extension=&grant_type=password"
- Working Response
Here is the working response:
{
"access_token" : "myAccessToken",
"token_type" : "bearer",
"expires_in" : 3600,
"refresh_token" : "myRefreshToken",
"refresh_token_expires_in" : 604800,
"scope" : "Meetings VoipCalling Glip SubscriptionWebhook Faxes Contacts RingOut SMS",
"owner_id" : "11111111",
"endpoint_id" : "22222222"
}

GCM response results is not having "Not Registered IDS" list

I am using curl to send push notifications using GCM. Here it is as follows:
curl --header 'Authorization: key=myAPiKey' --header 'Content-Type: application/json' https://android.googleapis.com/gcm/send -d '{"registration_ids":["registration_ids"], "collapse_key": "Turn", "data": { "title": "fdsfdsfsdfd","body": "fdsf dsf sd fsd fds fds fds", "badge": "1" , "content_available": 1 ,"url": "#/app/home"} }'
In reposnse I am getting as :
{"multicast_id":7729772425353298779,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]}
I am not getting registration_ids that are not registered. How Can I do this. I want this in curl only as i am using ruby 1.8.6 application.
Please help me on this

Elastic search batch insert using curl is not working

I'm performing a small benchmark on an Elastic Search cluster. My benchmark script is written in bash and uses curl.
I'm writing the data to a file that I'm posting to the REST API:
curl -XPOST 'localhost:9200/benchmark/external/_bulk?pretty' \
--data #$DATAFILE
My $DATAFILE is very simple, and has all newlines in place:
{"index":{"_id": "1"}}
{"data":"xxxxxxxxxx"}
{"index":{"_id": "2"}}
{"data":"xxxxxxxxxx"}
{"index":{"_id": "3"}}
{"data":"xxxxxxxxxx"}
...
But when I try to do my post I keep receiving the following error:
{
"error" : "ActionRequestValidationException[Validation Failed: 1: no requests added;]",
"status" : 400
}
I understand that my input is not validated, but why?
curl removed the newlines before the data was sent!
The --data parameter should be replaced with --data-binary:
curl -XPOST 'localhost:9200/benchmark/external/_bulk?pretty' \
--data-binary #$DATAFILE

Resources