Receipt is not in any Chunks from RPC - nearprotocol

I have the following transaction: 7gjmhdoPZcS5GQ5tbquEmzdoNXaVBmpTts6GidZZLzKM, which two receipts, the first of which is 4QJkVxdoc85VxnucLASBZykzygS3EiUyZ98eS1cAHa7L
Both the transaction and the receipt were executed in block 65694172. However, when using chunk via the RPC, the transaction is in one of the chunks (chunk 0), but the receipt isn't. It also isn't in any of the other chunks, or in any of the other blocks. Why is this?
Curl request that demonstrates the issue:
curl --location --request POST 'https://archival-rpc.mainnet.near.org' \
--header 'Content-Type: application/json' \
--data-raw '{
"method": "chunk",
"params": {
"block_id": 65694172,
"shard_id": 0
},
"jsonrpc": "2.0",
"id": 0
}'

Related

Update multiple Json with CURL POST

I would like to update multiple JSON filed in the same curl POST but I am not able to make it work.
I keep getting 400.
I tried checking online but was not able to find another way. Maybe there is an easier way of doing this but I am not sure what it is. Thanks for the help
I tried the following
curl -X 'PUT' \
'http://192.168.1.256:123/api/accessories/123456789' \
-H 'accept: */*' \
-H 'Authorization: Bearer $token' \
-H 'Content-Type: application/json' \
-d '{
"characteristicType": "Saturation",
"value": "30"
}
{
"characteristicType": "On",
"value": "1"
}'
curl -X 'PUT' \
'http://192.168.1.256:123/api/accessories/123456789' \
-H 'accept: */*' \
-H 'Authorization: Bearer $token' \
-H 'Content-Type: application/json' \
-d '{
"characteristicType": "Saturation",
"value": "30"
},
{
"characteristicType": "On",
"value": "1"
}'
curl -X 'PUT' \
'http://192.168.1.256:123/api/accessories/123456789' \
-H 'accept: */*' \
-H 'Authorization: Bearer $token' \
-H 'Content-Type: application/json' \
-d '[
{
"characteristicType": "Saturation",
"value": "30"
}
{
"characteristicType": "On",
"value": "1"
}
]'
You may test what comes to the server by using a dummy nc server in localhost with an arbitrary port such as in the example below:
$ nc -l 10000
And change this IP/port in the curl command, so the first example becomes:
curl -X 'PUT' \
'localhost:10000' \
-H 'accept: */*' \
-H 'Authorization: Bearer $token' \
-H 'Content-Type: application/json' \
-d '{
"characteristicType": "Saturation",
"value": "30"
}
{
"characteristicType": "On",
"value": "1"
}'
This is what the server will received:
$ nc -l 10000
PUT / HTTP/1.1
Host: localhost:10000
User-Agent: curl/7.68.0
accept: */*
Authorization: Bearer $token
Content-Type: application/json
Content-Length: 106
{
"characteristicType": "Saturation",
"value": "30"
}
{
"characteristicType": "On",
"value": "1"
}
How the server will parse this is implementation dependent.
In curl man page, it suggests using an ampersand (&) to add multiple data payloads. This can be done by the command itself by adding -d parameter multiple times:
curl -X 'PUT' \
'localhost:10000' \
-H 'accept: */*' \
-H 'Authorization: Bearer $token' \
-H 'Content-Type: application/json' \
-d '{
"characteristicType": "Saturation",
"value": "30"
}' \
-d '{
"characteristicType": "On",
"value": "1"
}'
Very certainly your server will not like the resulting syntax in the body though considering it's json.
As an additional note, be careful with using bash variables inside quoted strings. If they are single quoted instead of double quoted, they are not expanded. You probably should use -H "Authorization: Bearer $token" instead.

near-sdk-rs view account keys

I want to obtain in my smart contract the list of keys for a specific user. On RPC, I would do it like this:
curl --location --request POST 'https://rpc.mainnet.near.org/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "query",
"params": {
"request_type": "view_access_key_list",
"finality": "final",
"account_id": "account.near"
}
}'
What is the near-sdk-rs equivalent of this?
I know if I wanted to create keys, I'd use Promise::new(...).add_access_key(...). But I can't find any read operations here (and it wouldn't really make sense to use a Promise for a read anyways).
But surely it must be accessible to smart contracts, if it's accessible to the protocol. What am I missing?

How to send JSON body with curl to Postgrest

I'm trying to insert data on my Postgresql DB but I failed.
So basically I can select the data with the query below;
curl 10.127.18.18:3001/mytable
I can get all rows with this request.
I tried pretty much combination of the commands below but all of them failed. How can I insert a basic data with postgREST?
"mytable" table has 2 columns, "user_id" and "username";
curl POST 10.127.18.18:3001/mytable { "user_id": 3333, "username": testuser }
curl -X POST 10.127.18.18:3001/mytable HTTP/1.1 { "user_id": "3333", "username": "testuser" }
Thanks!
For those who encounter with the same problem, this query worked for me;
curl --location --request POST '10.127.18.18:3001/mytable' --header 'Content-Type: application/json' --data-raw '{ "user_id": "11", "username": "test" }'

Elasticsearch 6 create new field requires data type but "Indices created in 6.x only allow a single-type per index"

Create a new field in Elasticsearch 6.6.2 gives the following error:
{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: mapping type is missing;"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: mapping type is missing;"
},
"status": 400
}
The request:
curl --request PUT http://10.1.3.81:9200/netswitch_message/_mapping -H "Content-Type: application/json" -d \
'{
"properties": {
"amount": {"type": "integer"}
}
}'
gives error no matter what data type I use. The index already has types integer, text/keyword, text and date.
curl --request PUT http://10.1.3.81:9200/netswitch_message/_mapping -H "Content-Type: application/json" -d "{\"properties\": {\"amount\": {\"type\": \"integer\"}}}"
curl --request PUT http://10.1.3.81:9200/netswitch_message/_mapping -H "Content-Type: application/json" -d "{\"properties\": {\"amount\": {\"type\": \"text\"}}}"
curl --request PUT http://10.1.3.81:9200/netswitch_message/_mapping/data -H "Content-Type: application/json" -d "{\"properties\": {\"amount\": {}}}"
curl --request PUT http://10.1.3.81:9200/netswitch_message/_mapping -H "Content-Type: application/json" -d "{\"properties\": {\"amount\": {}}}
Expected to create a new field
Actually got syntax error:
{"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: mapping type is missing;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: mapping type is missing;"},"status":400}
You are right that 6.x restricts you to a single _type, but you do still need to supply the name of that type (in 7.x, it defaults to _doc).
Change your mapping to specify the _type, like the following which sets it to "my-type":
curl --request PUT http://10.1.3.81:9200/netswitch_message/_mapping/my-type -H "Content-Type: application/json" -d \
'{
"properties": {
"amount": {"type": "integer"}
}
}'
See: https://www.elastic.co/guide/en/elasticsearch/reference/6.6/indices-put-mapping.html#indices-put-mapping

Elasticsearch Delete Query By Date

I'm running the following query :
q='{
"filtered" : {
"query" : {
"match_all" : {}
},
"filter": {
"and": [
{
"range": {
"creation_time": {
"from": "2012-08-30",
"to": "2012-08-31",
"include_lower": true,
"include_upper": true
}
}
},
]
}
}
}'
My domain is an ec2 server
curl -XDELETE "http://#{mydomain}:9200/monitoring/mention_reports/_query?q=#{q}"
When I am hitting this query it gives me
curl: (3) [globbing] nested braces not supported at pos 118
Please help me thanks
If you’re trying to exec curl from the command line, it should be looking like:
q='YOUR_QUERY_CODE_GOES_HERE'
curl -v -H "Content-type: application/json" -H "Accept: application/json" \
-XDELETE -d $q http://localhost:9200/monitoring/mention_reports/_query
In case of inside-ruby execution, you should format the request as you do, but the silver bullet is still in headers:
-H "Content-type: application/json" -H "Accept: application/json"

Resources