Power Query API call POST method - powerquery

I have been trying to write this post request in Power Query but cannot seem to get it right
let
URL = "https://polkadot.api.subscan.io/api/scan/account/reward_slash",
headers = [#"Content-Type"="application/json", #"X-API-Key"="placeholder"],
data = Json.FromValue([tmode = 2, hold = 0, row = 20, page = 1, address = "placeholder"]),
web = Json.Document(Web.Contents(URL, [Content=data, ManualStatusHandling={404, 400}])),
#"Converted to Table" = Record.ToTable(web)
in
#"Converted to Table"
I am getting the following error:
Code: 400
message: address is a required field
I could use a hand figuring out how to pass the address in a way the API will respond to.
Here is a cURL request example from the documentation:
curl -X POST 'https://polkadot.api.subscan.io/api/scan/account/reward_slash' \
--header 'Content-Type: application/json' \
--header 'X-API-Key: YOUR_KEY' \
--data-raw '{
"row": 20,
"page": 1,
"address": "15fTw39Ju2jJiHeGe1fJ5DtgugUauy9tr2HZuiRNFwqnGQ1Q"
}'
Here are the docs for this specifc endpoint: https://support.subscan.io/#reward-slash

Related

Graph API List Channel Messages Returnng UnknownError after Protected API Request Approved

I am unable to get a good response, and having hard time finding Docs. Can't find a way to lookup the inner error code at all either. I get a token using
curl -L -X POST 'https://login.microsoftonline.com/51bcb6e4-b738-4e87-a795-768e3f13b94f/oauth2/v2.0/token' \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'client_id=5bbd5786-31d3-4d84-a8d0-a0dac6522f93' \ --data-urlencode 'scope=https://graph.microsoft.com/.default' \ --data-urlencode 'client_secret=<secret>' \ --data-urlencode 'grant_type=client_credentials'
and then take the access_token value, and do this
curl -L -X GET 'https://graph.microsoft.com/v1.0/teams/d89133ea-bf32-4957-8300-aa5e083f45c1/channels/19:5b075a993aee4b3fa8f23be2cbb3b514#thread.skype/messages' \ -H 'Authorization: Bearer <token value from above>'
But I get this error 403:
{ "error": { "code": "UnknownError", "message": "", "innerError": { "date": "2021-03-09T19:15:23", "request-id": "c9a8cf3a-b914-44a8-a66a-506634f09d77", "client-request-id": "c9a8cf3a-b914-44a8-a66a-506634f09d77" } } }
how can I troubleshoot? the url for the GET seems right, based on all my research. we are using resource specific consent permissions, but the app is installed in the channel that I am trying to list messages. from
This question will be tracked from here.

how to get list of flowfile from queue in nifi connection?

I want to get each flowfile from queue in connection when the flow was blocked with NiFi REST API.
I find that the functions of /nifi-api/flowfile-queues/{id}/listing-requests can meet my needs.And it response a ListingRequestDTO:
enter image description here
The field named flowFileSummaries can return a array of flowFile.And then I can get each uuid from flowfiles:
{
"uri": "value",
"uuid": "value",
"filename": "value",
"position": 0,
"size": 0,
"queuedDuration": 0,
"lineageDuration": 0,
"clusterNodeId": "value",
"clusterNodeAddress": "value",
"penalized": true
}
BUT,when I use the API and can not find the "FlowFileSummary"
{
"listingRequest": {
"id": "0165122a-e1ac-134e-2c09-92ba9ca93e8b",
"uri": "http://.../nifi-api/flowfile-queues/07a23828-d6f3-1e00-27af-f0428a493507/listing-requests/0165122a-e1ac-134e-2c09-92ba9ca93e8b",
"submissionTime": "09/07/2018 18:46:57.496 CST",
"lastUpdated": "18:46:57 CST",
"percentCompleted": 0,
"finished": false,
"maxResults": 100,
"state": "Waiting for other queue requests to complete",
"queueSize": {
"byteCount": 370689,
"objectCount": 995
},
"sourceRunning": false,
"destinationRunning": false
}
}
So, is there any possible solution to achieve? or any other solution? Thanks!
I don't believe the flow file summaries are available until the listing request is complete. In your example response above, note that finished is false. You can keep querying the API for that listing request until finished is true, then the summaries should be available. Then you can use the /flowfile-queues/{id}/flowfiles/{flowfile-uuid} and /flowfile-queues/{id}/flowfiles/{flowfile-uuid}/content endpoints to get the attributes and content of each flow file.
You do not need to have the listing request to complete. Here are the steps I used successfully to get the contents of flow file
Get the id of the Queue from NiFi UI console
Replace id here : curl -X POST https://myhost:443/nifi-api/flowfile-queues/{id}/listing-requests -H 'Authorization: Bearer ' --compressed --insecure
To get uris of flowfiles in the queue, get the value of 'uri' field from the response of the command in step2 and use it in next curl command, for ex:
For ex: curl -X GET https://myhost:443/nifi-api/flowfile-queues/0f66c88c-225d-3229-b2e1-597d8fba2c09/listing-requests/13802f9c-016a-1000-0000-00004eb033fb -H 'Authorization: Bearer ' --compressed --insecure
To get flow file content, get the value of 'uri' field from the response of the command in step3 and and use it in next curl command, for ex:
curl -X GET https://myhost:443/nifi-api/flowfile-queues/0f66c88c-225d-3229-b2e1-597d8fba2c09/flowfiles/7ccf5c54-7c8d-448a-a124-7f75f5845ec1?clusterNodeId=35a3df65-d7bf-47d2-b162-ea15c3c02c30 -H 'Authorization: ' --compressed --insecure
Note: if there are multiple flow files, you will see see multiple URIs in the response of step 3 curl command

How do I map the JSON body of a GET request to a parameter?

I have the following definition in my endpoint:
params do
requires :entities do
requires :id, type: String
optional :email, type: String
optional :phone, type: String
end
end
post "test" do
end
Note this only works as a POST request and the following CURL will work:
curl -XPOST localhost/test
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{ "entities": [{ "id": 3, "email": "test#abc.com" }] }'
However, the moment I change the declaration to get "test" instead of post, the corresponding curl request with -XGET no longer works due to the following validation error:
{"error":"entities is missing"}
If I remove the params requirements I can manually inspect the params hash at runtime and see that it only has a single key "route_info"
I'm currently using Grape 0.7.0
It happens because by specifying -d option you pass parameters in the body of the request while your endpoint is expecting them in the path as part of the url. Check here why it's a bad idea to pass body parameters in a GET request.
However, can use that option but if combination with -G.
-G, --get
When used, this option will make all data specified with -d, --data, --data-binary or --data-urlencode to be used in an HTTP GET request
instead of the POST request that otherwise would be used. The data will be appended to the URL with a '?' separator.
So that your get request by using -d would look like:
curl -XGET -G localhost/test
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{ "entities": [{ "id": 3, "email": "test#abc.com" }] }'

How can I send a parse push to an installation id or device token

How can I use the Parse REST API to push to a specific deviceToken or installation Id? I make the request and it succeeds with a 200 response but I get no push.
curl -X POST \
-H "X-Parse-Application-Id: XYZ" \
-H "X-Parse-REST-API-Key: FOO" \
-H "Content-Type: application/json" \
-d '{
"where": {
"deviceToken": "someId"
},
"data": {
"alert": "Willie Hayes injured by own pop fly."
}
}' \
https://api.parse.com/1/push

Android Retrofit ParseSdk Geopoint

I have some place data in parse database.
I would like to use retrofit to find closet place to given lat and longitude
Below is the link , and curl request.
https://parse.com/docs/rest/guide#geopoints-geo-queries
curl -X GET \
-H "X-Parse-Application-Id: xxxxxx" \
-H "X-Parse-REST-API-Key: xxxxx" \
-G \
--data-urlencode 'limit=10' \
--data-urlencode 'where={
"location": {
"$nearSphere": {
"__type": "GeoPoint",
"latitude": 30.0,
"longitude": -20.0
}
}
}' \
How can i convert above curl to retrofit call ?
I think i have to use QueryMap somewhere , but cannot figure out where.
This is what i have so far.
#GET("/classes/Place")
void getPlaces(#Query("limit") Integer limit,
Callback<PlacesResult> callback);
This is request with headers "X-Parse-Application-Id: xxxxxx", "X-Parse-REST-API-Key: xxxxx" and form url encoded body with #Query("where") that takes up string.
You can put these headers in http call Interceptor for all requests.
Yes, this can be done with QueryMap, which will be of two query params.

Resources