Retrieve count related lookup value using REST in SharePoint 2016 - rest

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.

Related

WooCommerce rest api include parameter not fetching variation with variable product

https://example.com/wp-json/wc/v3/products/10 product type=variable and it is working fine
https://example.com/wp-json/wc/v3/products/11 product type=variation and it is working fine
But it fetch only one product (with id 10) using include parameter like
https://example.com/wp-json/wc/v3/products?include=10,11
I need help so that i can fetch 2 or more products (any type) in one API call
Do you need to retrieve all the products in woo commerce. If try with this call " /wp-json/wc/v3/products"
A bit late but maybe someone has the same problem still
The include parameter should be array and as this thread explains How to pass an array within a query string?
you should send your parameters as this
https://example.com/wp-json/wc/v3/products?include[]=10&include[]=11

Proper multi-id syntax when using the custom_file_ids[] query parameter for the CLIO API "contacts" endpoint

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.

Rest API: How should the filter params send to API in case query based on nested resource

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/

How to delete only a subset of posted data in firebase

Posting data to firebase generate new items similar to the following example:
log
-K4JVL1PZUpMc0r0xYcw
-K4jVRhOeL7fH6CoNNI8
-K4Jw0Uo0gUcxZ74MWBO
I struggle to find how to e.g. delete entries that is older than x days - preferably with the REST API. Suggestions appreciated.
You can do a range query.
This technique requires you to have a timestamp property for each record.
Using orderBy and endAt you can retrieve all of the items before a specified date.
curl https://<my-firebase-app>.firebaseio.com/category/.json?orderBy="timestamp"&endAt=1449754918067
Then with the result, you can delete each individual item.

Sharepoint Online Rest Query with $expand generating 400 bad request

I have 2 sharepoint lists setup to represent different groups(circles) and the users that are apart of those groups(circles).
List: Circles Columns: Circle(single line of text)
List: UserCircles Columns: UserName(person lookup), UserCirlce(lookup to Circle list)
In the setup, all of the columns are their own columns (I have not renamed the title column to Circle or anything like that). I have not changed the display names of the lists.
When I try to run an REST GET against the UserCircles list and retrieve the projected values from the Circles list as below:
/_api/web/lists/getbytitle('UserCircles')/items?$select=Circles/Circle&$expand=Circles
I get a HTTP 400 Error and the message:
The field or property 'Circles' does not exist
I can successfully run a query against the UserName field (I assume that's the referenced field), by running the below query:
/_api/web/lists/getbytitle('UserCircles')/items?$select=Author/Title&$expand=Author
I am not sure why the query cannot find the list specified. I have verified all of the list names. Any guidance would be appreciated.
There is a typo in your example, since the name of lookup field is UserCirlce, the query should be like this:
/_api/web/lists/getbytitle('UserCircles')/items?$select=UserCirlce/Circle&$expand=UserCirlce
Note: the name of lookup field have to be specified in $expand query
option
The list of examples for syntax's of $expand query option:
/_api/web/lists/getbytitle('<listtitle>')/items?$select=<lookupfieldname>/<projectedfieldname>&$expand=<lookupfieldname>
/_api/web/lists/getbytitle('<listtitle>')/items?$select=<lookupfieldname>/<projectedfieldname1>,<lookupfieldname>/<projectedfieldname2>&$expand=<lookupfieldname>