Sharepoint Online Rest Query with $expand generating 400 bad request - rest

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>

Related

How to send multiple fields in the "word_similarity" PostgreSQL function

[See image here]
I have two fields in the table respectively name and note. Now I want to search words using the name and note both simultaneously. Here I have called the CriteriaBuilder function using the "word_similarity" key (I guess this 'word_similarity' is one internal function that works). Here you can see I passed the name field and got the result successfully.
But I want to search both fields simultaneously.
So how do I pass both fields (name and note) and get a search result? I am a new learner.
I would greatly appreciate all your suggestions.
I have tried to send multiple words like
cb.function("word_similarity", Double::class.java, root.get("name"), root.get("note"), cb.literal(s))
But not working.

How to define a tags / value query in Grafana 7.4?

I am having some trouble understanding the concept of Value groups/tags in Grafana 7.4.x with MySQL as a data source.
My main query gets the Countries
SELECT
NAME as __text,
id AS __value
from
countries
The tags query gets the Continents
SELECT
NAME as __text,
id AS __value
from
continents
That works so far, tags are shown in the list, but nothing happens once I click on them.
My tags query:
continents.$tag.*
The tags query seems to be the problem. Any help is greatly appreciated.
3 queries are involved:
The first one is under "Query Options" -> "Query": This one should list all the values (all the countries in your case).
The second query is the "Tags query" under "Value groups/tags": This query should list all the Tags you want (continents).
The third query is "Tag values query": This is where the magic happens, this query should return all the different values matching the selected tags, so, you must add a WHERE clause somewhere that Grafana will use to create a query to get the correct values, ...WHERE continent = '$tag'. <- $tag will automatically be replaced by a list of tags the user has chosen.
Be aware that the official documentation provides examples for InfluxDB datasource, since you are using MySQL, you must use SQL queries everywhere, so continents.$tag.* is invalid.

filtering the column value has more than 10000 list items in sharepoint 2013 rest api

_spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('ListName')/items?$top=5000&$filter= ColumnName eq 'abc'"
Here ColumnName is indexed. And there are more than 10,000 records having value "abc" in ColumnName. I am getting the error:
The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.
How can I fix this error? I need the column to be filtered even if it has more than 10,000 or above list items in SharePoint online.
This is known issue called list view threshold. For Sharepoint online, we suggest you index the column which you want to filter.
Below blog detailed explain about list view threshold, you may have a look:
https://natechamberlain.com/2018/05/21/how-to-resolve-sharepoint-list-view-threshold-error-the-view-cannot-be-displayed-because-it-exceeds-the-list-view-threshold/
https://support.microsoft.com/en-us/office/manage-large-lists-and-libraries-in-sharepoint-b8588dae-9387-48c2-9248-c24122f07c59?ui=en-us&rs=en-us&ad=us#__throttlesandlimits&ID0EAABAAA=Online

Retrieve count related lookup value using REST in SharePoint 2016

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.

SharePoint 2013 REST How to select a look up field and also filter based on look up field?

I can't select look up field in my SharePoint 2013 List.
also I can't filter base on a Look up field.
for example I have List with Name Test and this list has fields: Title, Company, Province
the Company and Province is look up fields I want to filter based on Province which is a look up field
using REST query it gives error:
my query:
https://TestServer/sites/AIB/OBC/_api/web/lists/getByTitle('Test')/items?$select=Province/Title&$expand=Province&$filter=Province/Title eq 'ABC'
it gives error when I put the URL in My browser for testing it gives the blow error:
<m:message xml:lang="en-US">The field or property 'Province' does not exist.</m:message>
How to filter based on a look up field in SharePoint 2013 REST ?
How to filter by lookup field value using SharePoint REST
Assume a Contacts list that contains a lookup field named Province
Option 1
When a lookup column is being added into list, its ID become accessible automatically via REST. For example, when the field named Province is added into List, Province Id could be set or get via ProvinceId property of List Item.
The following query demonstrate how to filter list items by lookup field Id (Province Id in our case):
/_api/web/lists/GetByTitle('<list title>')/items?$filter=LookupField eq <ProvinceId>
where <ProvinceId> is a province id
Option 2
In order to filter by lookup value, the query should contain $expand query option to retrieve projected fields (like Province Title). The following example demonstrates how to filter by lookup field value (by Province Title in our case):
/_api/web/lists/GetByTitle('Contacts')/items?$select=Province/Title&$expand=Province&$filter=Province/Title eq <ProvinceTitle>
where <ProvinceTitle> is a Title of Province
Use $expand like blow code:
/_api/web/lists/GetByTitle('Test')/items?$select=Province/Title&$expand=Province&$filter=Province/Title eq 'XYZ'
Mehdi jalal, I found why it was throwing that error. You need to close your ProvinceTitle with Single Quotes and there you have it. like this
Query Syntax:
/_api/web/lists/GetByTitle('Contacts')/items?$select=Province/Title,Province/ID&$expand=Province&$filter=Province/Title eq '<ProvinceTitle>'
Now this is Example Query:
/_api/web/lists/GetByTitle('Contacts')/items?$select=Province/Title,Province/ID&$expand=Province&$filter=Province/Title eq 'Detroit Province'