How to count users using Microsoft graph? - microsoft-graph-api

According to the documentation https://learn.microsoft.com/en-us/graph/query-parameters?#count-parameter
I should be able to get the count by using
https://graph.microsoft.com/beta/users?count=true
but it doesn't work...
Also I found that if I add ConsistencyLevel: eventual to the request header I do get a count but
it's not in the documentation so I'm not sure the count is the real user count
Am I missing something?

GET https://graph.microsoft.com/beta/users?$search="displayName:wa"&$orderby=displayName&$count=true
ConsistencyLevel: eventual
Please refer to this document which tells we need to use ConsistencyLevel: eventual
See also this article on the $count parameter:
https://learn.microsoft.com/en-us/graph/query-parameters?tabs=http#count-parameter

Related

How to pass in correlation id into IHttpProvider?

I need to pass correlation Id into the IHttpProvider to let them log it for debugging purpose. How should I do that? Thanks!
We don't have a great solution for you to provide your own correlation Id today, however it something that we are working on. Requests that are made to Graph will get assigned a request id and you should be able to see that in the response headers. You could add your own using header using .Request(options).

Provide the 'allowthrottleablequeries' preference to allow this

I have developed an API using Microsoft Graph API. I am encountering below issue.
URL that I am calling :
/v1.0/sites/root/lists/cb32cc85-5351-423d-b2ec-bb418c1d9c64/items?
$filter=fields/Created gt '2018-1-1T00:00:00'
&expand=fields
&$orderby=createdDateTime
&$top=10
Error returned from the API :
Field 'Created' cannot be referenced in filter or orderby as it is not indexed. Provide the 'allowthrottleablequeries' preference to allow this, but be warned that such queries may fail on large lists.
How to enable allowthrottleablequeries as it says and how should I achieve this?
I'm afraid this isn't a very clear or useful error message. As far as I know, there isn't actually a way to enable allowthrottleablequeries.
This happens when a SharePoint list grows too large to handle filtering or sorting non-indexed columns. The fix is to add an index to the created column in your List Settings. You can find instructions on how to accomplish this in Add an index to a SharePoint column.
Try to send your request with following Request Header
Prefer: allowthrottleablequeries
If it does not work then try the following Request Header
Prefer: HonorNonIndexedQueriesWarningMayFailRandomly

How to search for a message by a specific ts

I am trying to get the parent message of a threaded reply with the Slack API. When a new reply is put, it has a "thread_ts" attached to it, which corrsponds to its parent message's "ts". I tried to do a searchall with the ts as the query but this didn't work. How would I do this?
See Slack's docs on retrieving a single message with channels.history. This "selecting 1 item from a range" approach should also work with other channel history methods and conversations.history.
The easiest way is to provide the thread_ts value you want to look up as the latest parameter to conversations.history, along with the containing channel ID as channel, and a limit of 1 to ask for a single message. You will need the corresponding *:history scope to make the request.
Example:
GET /api/conversations.history?token=TOKEN_WITH_CHANNELS_HISTORY_SCOPE&channel=C2EB2QT8A&latest=1476909142.000007&inclusive=true&limit=1

Select fields on Microsoft Graph list of Messages

I'm using Microsoft Graph to get a list of messages for a user.
I'm using the following URL
https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages
One important thing that is returned by this is the meetingMessageType when the message revolves around a meeting request.
I would also like to get the uniqueBody of the message. However, that's not provided by default. One needs to specifically ask for that field. I can do that by adding ?$select=uniqueBody to the URL.
However, that now means that I need to add the rest of the fields I want to the $select query parameter. That's not a big deal until I run into meetingMessageType. Microsoft Graph returns:
Could not find a property named 'meetingMessageType' on type 'Microsoft.OutlookServices.Message'.
What can I do to ensure I get both uniqueBody and meetingMessageType?
Try this:
$select=uniqueBody, microsoft.graph.eventMessage/meetingMessageType
Yogesh's answer is close but will result in a Only one level select is supported error.
As long as you don't care about the value of meetingMessageType, you can use this select:
$select=microsoft.graph.eventMessage, uniqueBody
You'll note that the results no longer include meetingMessageType as a property. The list however is limited to only those messages that are eventMessage, effectively giving you a result set filtered to only show meeting requests.

ITunes Search API page number for the query

Is there any way to get results of next page of a search query? When I give page parameter, I get the same results from ITunes as:
https://itunes.apple.com/search?country=us&limit=200&entity=software&term=a
and
https://itunes.apple.com/search?country=us&limit=200&entity=software&term=a&page=2
gives the same output. Giving page parameter works for customer reviews.
Is there any way to get the results of next page?
According to API documentation there is no way but I found a lot of useful answers which are not indicated in API documentation.
I found a way to query more records. There is a parameter called offset, which is not mentioned in API documentation.
https://itunes.apple.com/search?term=a&offset=25&limit=25
Enjoy!
Actually there is no pagination in apple search API. It will only return maximum first 200 records.
Below is reference URL for same:
https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/#searching
Thank you.

Resources