How to fetch the SharePoint User Profile with Graph API - azure-active-directory

Here's what I tried:
https://graph.microsoft.com/v1.0/sites/{SiteID}/lists/{ListID}/items&filter=startswith(fields/Title,'Annette')
however I got the following error
"message": "Bad Request - Error in query syntax.",
How can I fetch the profile of the users from Sharepoint list that starts with "Annette"

Append "?" symbol after items keyword.
Like :
https://graph.microsoft.com/v1.0/sites/{SiteID}/lists/{ListID}/items?&filter=startswith(fields/Title,'Annette')
It would work as expected ,as I reproduced same in my lab.

Related

Getting 'Missing argument' error when calling Quip API - add members method

I'm trying to use the Quip admin and automation APIs to add members to a document from a Salesforce trigger.
I've successfully used the GET methods for verify token and get user from the automation API, but I'm getting an error when I call add members from the Admin API. The error I'm getting is 'Missing argument thread_id', despite passing in a valid thread id. If I copy the body from the request into Postman it works fine. The Salesforce org is a developer sandbox.
These are the debug lines from Salesforce:
USER_DEBUG [332]|DEBUG|System.HttpRequest[Endpoint=https://platform.quip.com/1/admin/threads/add-members?company_id=JKNAcB0VIMy, Method=POST]
USER_DEBUG [336]|DEBUG|Body req = {"thread_id":"eNiVAcaDICco","member_ids":"KPDAFRZtNRW"}
USER_DEBUG [337]|DEBUG|Body response = {"error":"application_error","error_code":400,"error_description":"Missing argument 'thread_id'"}
USER_DEBUG [339]|DEBUG|Method = POST
USER_DEBUG [340]|DEBUG|Scope = USER_READ ADMIN_MANAGE
USER_DEBUG [341]|DEBUG|Authorisation = Bearer UkRQQU1AcXymZ1M=|1692717157|N4CCVoKA8MY4sNF/+mBeWzX5lXAeI/q/YKxSMhC9PJc=
Any help would be much appreciated
I found the issue, it was the content-type in the header, it needed to be set to set to application/json

query data in a airtable database using url

I want to implement URL for search specific data in my base using filterByFormula
below are my link and I got an error and how to resolve that
my url:
api.airtable.com/v0/APPID/Stories?filterByFormula=(FIND(“Car (in robot form) will offer a hug when I am stressed out”,{User want}) &api_key=MYKEY
Error :
{
"error": {
"type": "INVALID_FILTER_BY_FORMULA",
"message": "The formula for filtering records is invalid: Invalid formula. Please check your formula text."
}
}
I tried using postman, please help me.
While querying filtered data from Airtable via API, you don't have to use FIND keyword. You can filter data with simple Airtable formula like structure. For example,
{Email} = 'johnwick#neverdie.com'
Above filter retrieve all the records from the table whose Email is simply johnwick#neverdie.com
To limit number of records retrieve by API maxRecord parameter is available for that. For more info about various parameters please refer my answer here AirTable API Find record by email or official Airtable API Documentation
In your case
API url would be structured like,
api.airtable.com/v0/APPID/Stories?filterByFormula=Car+(in+robot+form)+will+offer+a+hug+when+I+am+stressed+out%3D%22User+want%22&api_key=MYKEY
For more info about Airtable API encoding, check this https://codepen.io/airtable/full/rLKkYB?baseId=app1C5TVoophmmr8M&tableId=tblvILr4aSAYI98oa
Hope this helps!

Ability to filter users with onPremisesSamAccountName with Microsoft Graph API

I would like to filter Users from Microsoft Graph API based on onPremisesSamAccountName, which is currently not available with Graph API.
We have the internal employee id to be stored with onPremisesSamAccountName variable which is present in users API of Microsoft Graph. We are trying to filter with onPremisesSamAccountName property to filter based on the internal employee id. Currently, we are not able to do that with Graph API but we really need this to be working or would be happy if we get to know any possible workarounds.
https://graph.microsoft.com/v1.0/users?$filter=onPremisesSamAccountName eq '[some-id]'&$select= userPrincipalName,displayName,department,jobTitle,companyName,onPremisesSamAccountName,....[more list of fields for select]
The expected outcome is to show the required result but the response what we got is as follows:
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported or invalid query filter clause specified for property 'onPremisesSamAccountName' of resource 'User'.",
"innerError": {
"request-id": "[request-id from request]",
"date": "[date on which request is made]"
}
}
}
As you can see, the filter is not supported for property 'onPremisesSamAccountName'.
If you do have this requirement, you can post your idea at Microsoft Graph UserVoice.
I was able to do a filter using onPremisesUserPrincipalName - you could check what is returned using this property and see if you can make it work

How to update a Azure AD user?

I have successfully created a new user in Azure AD following Create User reference.
Now I want to update that very same user following Update User reference. To keep things simple This is the JSon content I'm sending:
{
"userType": "T"
}
The documentation tells me to send a PATCH request, but I always receive an HTTP Error 400 (Bad request). If I try sending a POST request I receive an HTTP Error 405 (Method not allowed).
The destination URL is https://graph.microsoft.com/v1.0/users/user-id.
The user-id is the one returned with the user details.
What am I missing?
Update 1
Those are the permissions set to the application:
This is exactly how you update user (PATCH).
However the userType property cannot be T, from the docs you refer:
That property can only have one of the two distinct values: Member or Guest.
Of course, the user-id in path should the id property as returned by the get users operation.
I am pretty sure that if you use a normal REST client will be able to see the whole error message, which will be more meaningful.
If you still have issue - paste the exact error message.

Microsoft Graph API - Get directory objects from a list of ids - Bad request

I need to get a list of groups that the user is a member of using Microsoft Graph API.
For this, I am using the endpoint POST /users/<userId>/getMemberGroups (doc). This works fine but the problem is that the response is only a list of group object ids. I need to get group properties too. I could just loop through the list and query API for GET /groups/<groupId> but this takes too long when the user has multiple groups.
Then I found POST /directoryObjects/getById (doc) which turns that list into what I need. I have followed the doc page exactly but I am getting the following error:
Request_BadRequest - Specified HTTP method is not allowed for the request target. (HTTP status 405)
What am I doing wrong? Is the method getById bugged? If it is, is there any alternative way to turn a list of group object ids into groups or to get full list of user groups?
The API Get directory objects from a list of ids you mentioned should work, I test it in the MS Graph Explorer, it works fine.
Make sure you use POST method, I can reproduce your issue with another method.
You could refer to the informations below and try again.
Request URL:
POST https://graph.microsoft.com/beta/directoryObjects/getByIds
Request Body:
{
"ids": [
"xxxxxxxx-9f1b-4f28-a408-xxxxxxxxxxxx",
"xxxxxxxx-a614-4335-81eb-xxxxxxxxxxxx",
"xxxxxxxx-e500-49d6-a705-xxxxxxxxxxxx",
"xxxxxxxx-5be3-41eb-864d-xxxxxxxxxxxx",
"xxxxxxxx-961d-4db9-87cf-xxxxxxxxxxxx",
"xxxxxxxx-93bf-4950-8d96-xxxxxxxxxxxx"
],
"types": [
"group"
]
}
Result:

Resources