There is any way to get the table count in rest mode?
I'm using query params like:
https://urt.to.supabase/rest/v1/table?select=field,another_field
I was googling it out but without success.
What you need to do is to add Prefer: count=exact to the request header.
Example of this using curl would be like this:
curl "https://urt.to.supabase/rest/v1/table?select=field,another_field" -I \
-H "Prefer: count=exact"
The count value will be the number after / on the content-range header on your response. In the following example, row count is 3573458.
Content-Range: 0-24/3573458
You can read more about it on postgrest documentation here.
Note that with the Supabase.js library, you easily get the count of
const { data, error, count } = await supabase
.from('cities')
.select('name', { count: 'exact' })
You can read more about it on the official docs.
Related
is there a working REST curl to get all worklog of every issue there is,
I ve tried POST /rest/api/2/worklog/list , but I dont have a list of worklog ids !!
and I don't wanna go through issues either
you can try this POST API : /rest/tempo-timesheets/4/worklogs/search which required few request body params as : {"from":"2018-11-01","to":"2018-11-30","epicKey":["epic-key1"],"projectKey":["project-key1"]}.
If you do not want to go through all the issues, you can get the worklog IDs via Get ids of worklogs modified since REST API. The response body will contain the IDs you can use for /rest/api/2/worklog/list.
You will have to go through issues. The fastest way is to execute a search with JQL query: worklogDate > 0 that will return all the issues that have any worklogs. Then you will have to ask for worklogs of each returned issue.
Both resources, search results and worklogs of issue are paginated resources so you will have to iterate to get all the worklogs of all the issues (unless you have a small instance).
IDS=$(echo {1001..2000} | tr ' ' ',') && curl \
-u username:password \
-X POST \
--data '{"ids":['$IDS']}' \
-H "Content-Type: application/json" https://jira.com/rest/api/2/worklog/list
I'm using the graph API and trying to get a list of ads with their insights and post images.
I don't want to do multiple queries for this as I quickly hit the "(#17) User request limit reached" issue even when I use batch queries.
My current query looks like this:
/ACCOUNT_ID_HERE/ads?fields=insights{cpc,reach,spend,clicks,ctr},status,creative
Now in order to get the post image, I need to take the creative ID that is returned and use it in another query to pull the post like this:
/CREATIVE_ID/?fields=object_story_id
Then use the returned story id to pull the picture like:
/OBJECT_STORY_ID/?fields=picture
Is there any way I can combine these queries to do less requests?
Something like:
/ACCOUNT_ID_HERE/ads?fields=insights{cpc,reach,spend,clicks,ctr},status,creative{object_story_id{picture}}'
Any help is appreciated. Thanks.
Facebook's Batch API may work for you. It allows for multiple Graph API calls to be made from a single HTTP request and supports dependencies between those requests. Read over the documentation for details and here's a example curl call of how it might work (I've not executed this call so please review against the API documentation and test).
curl \
-F 'access_token=...' \
-F 'batch=[
{
"method":"GET",
"name":"ads",
"relative_url":"/ACCOUNT_ID_HERE/ads?fields=insights{cpc,reach,spend,clicks,ctr},status,creative",
},
{
"method":"GET",
"name":"creative",
"relative_url":"/{result=ads:$.data.*.creative}/?fields=object_story_id"
},
{
"method":"GET",
"relative_url":"/{result=creative:$.data.*.object_story_id}/?fields=picture"
}
]' \
https://graph.facebook.com
In my server side Meteor.js method, I'm trying to correctly make a request to Domino Data Lab's (DDL) Rest API.
DDL provides a platform for makes it possible to call a data science model via a REST API. Their documentation on this API is here:
http://support.dominodatalab.com/hc/en-us/articles/204173149-API-Endpoints-Model-Deployment
But, I doubt the documentation is helpful because I think an experienced Meteor developer will see the request examples in CURL or Python and know how to get the params correctly into the JSON format that DDL is looking for.
Domino Datalab provides the instructions for 4 methods, but not for Meteor.js. I'll post the examples for Curl and Python:
Examples
CURL Request
curl -v -X POST \
https://app.dominodatalab.com/MYURL \
-H 'Content-Type: application/json' \
-H 'X-Domino-Api-Key: YOUR_API_KEY' \
-d '{"parameters": [ "FOO", "BAR", "ETC"]}'
Python Request
import requests
response =
requests.post("https://app.dominodatalab.com/MYURL",
headers = {
"X-Domino-Api-Key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
json = {
"parameters": ["FOO", "BAR", "ETC"]
}
)
print(response.status_code)
print(response.headers)
print(response.json())
I've tried a few different ways (using both the dataand paramsoptions) based on the documentation for Meteor, but here is my best try:
Meteor.methods({
score_app: function(){
var test = HTTP.call("POST", "https://app.dominodatalab.com/MYURL",
{ headers: {
"Content-Type": "application/json",
"X-Domino-Api-Key": "YOUR_API_KEY"
},
// This is where the problem is. Have tried multiple syntax versions and tried using the `params`options for the HTTP call instead of `data`
data: {'params': [143]
}
},
function (error, result) {
// The syntax below should be if not an error, log the result (for testing etc, otherwise, log "http post error". I may have incorrectly switched this around, but the original version I got from an online example had it the console.log statements in the reverse order.
if (!error) {
console.log(result);
} else{
console.log("http post error");
};
});
}
});
I've been using this entry in the Meteor documentation to send the parameters as a JSON object correctly:
http://docs.meteor.com/api/http.html
The connection to Data Domino Lab (DDL) is made correctly, but it doesn't recognize the parameters correctly because the request is not sending the parameters in the JSON format that DDL wants.
result: 'You must provide a JSON object in your request body
with a parameters key containing an array of parameters.' } }
I'm on the DDL free plan, but I will email a link to this question to their tech support. This is a niche issue, but it could be important to Meteor.js developers in the future wishing to link to a data science model in DDL.
I'm one of the engineers at Domino who has worked on the API Endpoints feature recently. The error
message you're getting means that the JSON object you're sending to our server doesn't contain the
key "parameters". I'm not an expert in Meteor, but it looks like you're using "params" where you
should use "parameters" in your JSON payload.
Around line 9 can you change...
{'data': {'params': [143]}}
to
{'data': {'parameters': [143]}}
If my understanding of your code is correct, that'll work correctly.
Cheers!
we use the REST API for OpenStack Object Store(Swift).
guessing the following structure does exist in the OpenStack Object Store:
/containername/object1.txt
/containername/object2.txt
/containername/pseudo-directoryname/object3.txt
/containername/pseudo-directoryname/object4.txt
To get a list of objects from a container we can use a HTTP GET request with the specified URL.
So far so good. Result:
/object1
/object2.txt
/pseudo-directoryname/object3
/pseudo-directoryname/object4.txt
The GET request combined with a delimiter parameter ("URL+ABSOLUTEPATH?delimiter=/") cuts the pseudo directories from the result.
/object1.txt
/object2.txt
I would like to have a list of all objects within the container combined with the pseudo directories within the container.
Is there a solution to get the following result without getting all objects and parse them on client side?
/object1.txt
/object2.txt
/pseudo-directoryname/
I didn't find anything about wildcards when using the delimiter parameter.
Something like "URL+ABSOLUTEPATH?delimiter=/*/".
I was just trying to work the same thing out. Found the answer in the docs: http://docs.openstack.org/user-guide/cli_swift_pseudo_hierarchical_folders_directories.html#list-pseudo-hierarchical-folders-request-http
Using their example (note the prefix and delimiter query string parameters):
$ curl -X GET -i -H "X-Auth-Token: $token" $publicurl/v1/AccountString/backups?prefix=photos/&delimiter=/
Would return:
photos/animals/
photos/me.jpg
photos/plants/
Hitting the Facebook graph api with a batched request:
curl -F 'access_token=mytoken' -F 'batch=[{ "method":"GET","relative_url":"me?fields=name,first_name,last_name,picture.width(100).height(100),email", "include_headers":"false"},
{ "method":"GET","relative_url":"me?fields=picture.type(large)", "include_headers":"false"}]' https://graph.facebook.com/v2.2
The result still contain the headers.
I don't expect them in the result.
Is the "include_headers":"false" syntax wrong or misplaced?
Thanks a lot.
I was able to exclude the headers in batch requests a few different ways. I'm doing it from the PHP SDK but it's all the same under the covers.
By passing it as a POST parameter on the top-level request, i.e. add -F "include_headers=false" to your curl command
By passing it as a GET parameter on the inner request(s), not as a separate field, i.e. append "&include_headers=false" to relative_url
Hope that helps!
If you're using the python facebook-sdk this does the trick:
rezs = self.graph.request("?include_headers=false",
post_args={"batch": batched_requests})
where my self.graph is:
self.graph = facebook.GraphAPI(access_token=access_token,
version="2.5")
and the batched_requests is a string containing the IDs and fields that I want.