Send Asked Data#
send_asked_dataAPI-v2 send_asked_data #
The send_asked_data method is a utility RPC used mainly by front-end or plugin components to reply to an earlier ask_for_data request emitted by the node.
When another part of the system (for example, a GUI) needs some data, it calls ask_for_data which broadcasts an internal DataNeeded event with a data_id.
Your component then gathers the requested information and posts it back via send_asked_data.
Request Parameters#
Parameter Type Required Description data_id integer
✓
Identifier supplied by the original DataNeeded event. data object
✓
Arbitrary JSON value satisfying the original request.
Response Parameters#
Parameter Type Required Description result boolean
✓
true on success.
📌 Example#
JSON Bash Python JavaScript PHP Go Ruby
Copy
{
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "send_asked_data" ,
"id" : 0 ,
"params" : {
"data_id" : 42 ,
"data" : {
"name" : "Komodo"
}
}
}
Copy
curl --url "http://127.0.0.1:7783" --data '{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "send_asked_data",
"id": 0,
"params": {
"data_id": 42,
"data": {
"name": "Komodo"
}
}
}'
Copy
import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "send_asked_data" ,
"id" : 0 ,
"params" : {
"data_id" : 42 ,
"data" : {
"name" : "Komodo"
}
}
}
response = requests.post(url, json = payload)
print (json.dumps(response.json(), indent = 2 ))
Copy
const payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "send_asked_data" ,
"id" : 0 ,
"params" : {
"data_id" : 42 ,
"data" : {
"name" : "Komodo"
}
}
};
const response = await fetch ( "http://127.0.0.1:7783" , {
method: "POST" ,
body: JSON . stringify (payload),
});
console. log ( await response. json ());
Copy
<? php
$payload = <<< ' JSON '
{
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "send_asked_data" ,
"id" : 0 ,
"params" : {
"data_id" : 42 ,
"data" : {
"name" : "Komodo"
}
}
}
JSON ;
$ch = curl_init ( "http://127.0.0.1:7783" );
curl_setopt ($ch, CURLOPT_POST , true );
curl_setopt ($ch, CURLOPT_POSTFIELDS , $payload);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER , true );
curl_setopt ($ch, CURLOPT_HTTPHEADER , [ 'Content-Type: application/json' ]);
$response = curl_exec ($ch);
curl_close ($ch);
echo $response;
Copy
package main
import (
" bytes "
" fmt "
" io "
" net/http "
)
func main () {
payload := [] byte ( `{"userpass":"RPC_UserP@SSW0RD","mmrpc":"2.0","method":"send_asked_data","id":0,"params":{"data_id":42,"data":{"name":"Komodo"}}}` )
resp, err := http. Post ( "http://127.0.0.1:7783" , "application/json" , bytes. NewBuffer (payload))
if err != nil {
panic (err)
}
defer resp.Body. Close ()
body, _ := io. ReadAll (resp.Body)
fmt. Println ( string (body))
}
Copy
require 'net/http'
require 'json'
require 'uri'
uri = URI ( "http://127.0.0.1:7783" )
payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "send_asked_data" ,
"id" : 0 ,
"params" : {
"data_id" : 42 ,
"data" : {
"name" : "Komodo"
}
}
}
response = Net :: HTTP . post (uri, payload. to_json , 'Content-Type' => 'application/json' )
puts JSON . pretty_generate ( JSON . parse (response. body ))
Show Send Asked Data Response {
"mmrpc" : "2.0" ,
"result" : true ,
"id" : 0
}
Error Types#
Parameter Type Required Description NotFound integer
–
No awaiting ask_for_data with the specified data_id. Internal string
–
Internal error while delivering data (rare).