I am having students model in loopback which is accessible via rest using this url. /api/students rest call gives all the student data but I want to get only the registration numbers (regno) of students. Like in sql (SELECT regno FROM students). how I should filter the above rest call to get only the registration numbers of students.
?filter={"fields":"regno"}
If you want to get multiple columns
?filter={"fields":["regno","column2","column3",....]}
Use the fields filter.
?filter[fields][regno]=true
https://docs.strongloop.com/display/public/LB/Fields+filter
Related
What is the correct API syntax for using the custom_file_ids[] query parameter to specify multiple fields (but not all) in the CLIO API contacts result set? I need to specify multiple custom fields. I can get it to work for a single field, but not multiple fields at the same time.
Specifically, how do I specify and delimit the multiple fields? I have tried the following:
custom_file_ids[]=1234567,2345678
custom_file_ids[]=[1234567,2345678]
custom_file_ids[]=(1234567,2345678)
custom_file_ids[]={1234567,2345678}
custom_file_ids[]=1234567:2345678
The API documentation at https://app.clio.com/api/v4/documentation is silent on the list syntax that it expects.
Below is one specific API call I tried (both the actual URL-encoded call, and a decoded one for clarity) using a simple comma-delimited list, but which only returns custom field data for the first ID in the list--not the second. If I enclose the ID list in any kind of brackets (per above), the endpoint returns a 404 error.
https://app.clio.com/api/v4/contacts?custom_field_ids[]=1234567%2C2345678&custom_field_values[4529224]=true&fields=id%2Cname%2Cprimary_address%2Cprimary_work_address%2Cis_client%2Ctype%2C%20primary_email_address%2Cprimary_phone_number%2Ccustom_field_values%7Bid%2Cfield_type%2Cfield_name%2Cvalue%2Ccustom_field%7D
https://app.clio.com/api/v4/contacts?custom_field_ids[]=1234567,2345678&custom_field_values[4529224]=true&fields=id,name,primary_address,primary_work_address,is_client,type,primary_email_address,primary_phone_number,custom_field_values{id,field_type,field_name,value,custom_field}
Try:
custom_file_ids[]=1234567&custom_file_ids[]=2345678
I was able to do this with Contacts Custom Fields by putting custom_field_id[] on the URL as many times as you have IDs.
I hope this helps.
I am following this post:
http://pawansatope.blogspot.com/2012/01/how-to-create-count-related-lookup.html
Now I want to get the same results(i.e DepartmentTitle and NbOfEmployees) values programatically using the REST api.
I've tried different variations of:
/items$select=Title,NbOfEmployees/...&$expand=NbOfEmployees
but haven't got any luck.
Has anyone tried this?
Many thanks!
I created the lookup field "NbOfEmployees" (Department(Count Related) to Employee Data list like this:
This is the two list data:
Then for NbOfEmployees field (Department count), directly get in Rest API:
http://sp2016/_api/web/lists/getbyTitle('Department')/items?$select=NbOfEmployeesId,Title
Actually, this value is the real count value for department, no need to expand in Rest.
Is it possible to pass parameters with 'like' keyword in REST api endpoints. Basically I'm trying to create an endpoint wherein I would query a db to get list of items based on '%name%'.
The corresponding query in DB would be like:
SELECT * FROM users WHERE user_id like "%arjun%"
So I would need to add parameters to my REST endpoint wherein i can fetch teh data based on name=%arjun%
Is that really possible?
Thanks
Arjun
I would recommend to user name=value and then create your sql with %%. You can put % into your GET call but it can cause bugs because % is special character which is used to encode other special characters.
But if you really want to go with name=%value% then you can put %25 instead of %. So something like this name=%25value%25
I have two entities Properties and Bookings.
I need to know the URL structure in case I'm filtering the properties base on query on bookings.
In my case I need to get the properties which are free (not occupied) at specific date.
Can it be
api/properties/free/{date}
Or
api/properties/bookings?bookingDate!='1-1-2017'
Or
api/properties?bookingDate!='1-1-2017'
it seems for me that the last one is the more appropriate but the filter is on the bookings not on the properties which is not obvious.
The Facebook Graph API has a interesting way of doing nested queries by using a strategy of fields filter.
The fields filter it´s a way of filter specific fields or nested fields of a rouserce. They also create a standard way to inform functions for every selected field like: limit or equal.
Your request would be something like this:
GET /api/properties?fields=bookings{bookingDate.notEqual('1-1-2017')}
For more information about Facebook´s GraphAPI:
https://developers.facebook.com/docs/graph-api/overview/
When I update an invoice in QB (after its been changed in my system), I want to avoid updating anything that the user has modified in QB. My plan was to use the filter API method and filter by Ids to get the list of invoices from QB that my app created. However, it doesn't look like InvoiceFilter accepts ListIdSet. It does have a TransactionIdSet, but I can't find a way to get ahold of that number (i.e., the TransactionId) via Data Services. It's certainly not in the response when invoices are read. So, how do I query for a specific set of invoices via the API?
The transaction id refers to the id of the invoice here.
For eg, the following invoice query will retrieve the invoice with Id 4 -
<InvoiceQuery xmlns="http://www.intuit.com/sb/cdm/v2">
<TransactionIdSet>
<Id idDomain="QB">4</Id>
</TransactionIdSet>
</InvoiceQuery>