Azure GraphAPI getMemberGroups Bad Request error - azure

I am attempting to make the Azure Graph API call getMemberGroups, however I am getting a "400 Bad Request" error in response.
According to the documentation [https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/functions-and-actions#getMemberGroups], the following request should be :
I am using POSTMAN to make the request however I keep getting a "Request_BadRequest" error code.
My POST request is:
Where the red bar is the tenant ID and the blue bar is the object ID of the user.
My headers are:
My body is:
I keep getting the error message:
{
"odata.error": {
"code": "Request_BadRequest",
"message": {
"lang": "en",
"value": "Invalid JSON. The value '------' is not a valid number."
}
}
}
I am not too sure why that is happening, does anyone have any clues?

Since we are posting the json data, you shouldn't use the form-data. For the application/json type data, we should use the raw option to send the data.

How to know the authorization token of the Ad User

Related

404 not found. Using postman for stripe integration in android studio

I added the url for customers, emphemeral keys and payment_intent in the postman, and then i added authorization, body and sent the url request. Customers is working but for emphemeral key and payment_intent, i get the 404 error even though I used all details from stripe documentation
{
"error": {
"message": "Unrecognized request URL (GET: /v1/ephemeral_keys). Please see https://stripe.com/docs or we can help at https://support.stripe.com/.",
"type": "invalid_request_error"
}
}
The /v1/ephemeral_keys only accepts the POST verb.

Filter with drivetype in Graph API giving invalid filter clause error

My requirement is to get only the document library list of SharePoint via Rest API.
I added Files.ReadWrite.All application permission and got token with scope: https://graph.microsoft.com/.default
To filter only document library of SharePoint, I'm using this:
GET https://graph.microsoft.com/v1.0/sites/siteid/drives?$filter=(driveType eq "documentLibrary")
This threw me "400 Bad Request". I have no idea why I am getting this error. The complete error looks like:
{
"error": {
"code": "BadRequest",
"message": "Invalid filter clause",
}
}
Did anyone face the same scenario? I am totally confused. How to get rid of it? How to add filters in the Graph api query?
I tried to reproduce same in my environment and got below results:
I created one Azure AD application and granted API permission like below:
I got the access token via Postman with same scope as below:
POST https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token
client_id: client_id
grant_type:client_credentials
client_secret: client_secret
scope:https://graph.microsoft.com/.default
Response:
When I used the above token to call below query, I got the same error as you:
GET https://graph.microsoft.com/v1.0/sites/<siteID>/drives?$filter=(driveType eq "documentLibrary")
Response:
To resolve the error, try modifying your filter query like below:
GET https://graph.microsoft.com/v1.0/sites/<siteID>/drives?$filter=driveType eq 'documentLibrary' &$select=id,createdDateTime,name,webUrl,driveType
Response:

How to get a list of channels in Microsoft Teams using MS Graph?

I'm getting the user's token and submitting a request to /me/joinedTeams and get the teams IDs of the user.
For each team id, I want to get a list of available channels by sending a request to /teams/{id}/channels, however i am getting the following error:
{
"error": {
"code": "Forbidden",
"message": "Failed to execute Skype backend request GetThreadS2SRequest.",
"innerError": {
"date": "2021-03-12T07:08:38",
"request-id": "2f1b9408-e7db-4245-be6f-0ec6d67ff160",
"client-request-id": "2f1b9408-e7db-4245-be6f-0ec6d67ff160"
}
}
}
How do I fix this?
After which I want to send a request to /teams/{id}/channels and get drive-id.
And at the end, for each drive-id, get a list of files - /drives/{drive-id}/root/search(q='').
As I said in the comments, this api call does not support personal accounts, you must use a work account.
This is my test result:

How to update existing user in Azure AD using Microsoft Graph API

I have added a user in azure ad. Now using graph api I want to update its display name or let say password. I am referring to this guide https://learn.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&tabs=cs
First of all, I am not sure I am using correct URL to update the user but below is what I am using:
https://graph.microsoft.com/v1.0/users/john#<myorg>.onmicrosoft.com
I am passing the userName of the user which I want to udpate in the url. Please let me know if this is not correct.
I am including the OAuth token as bearer token in my request and posting the below json:
{
"accountEnabled": true,
"displayName": "john12"
}
From the above json, I want to change the display name from john to john12. But I am getting below error:
{
"error": {
"code": "Request_BadRequest",
"message": "Specified HTTP method is not allowed for the request target.",
"innerError": {
"request-id": "536fd7c1-db46-4927-9732-169da778811c",
"date": "2019-06-06T04:58:26"
}
}
}
Please can anyone please let me know how can I update the existing user properties. Thanks
Most probably you're not using HTTP method PATCH. I say this looking at the error message Specified HTTP method is not allowed for the request target.
If you use anything other than PATCH, like a POST you will end up getting this error message.
The JSON body for your request looks fine. I tried updating an existing user with similar JSON and sending a PATCH request from Microsoft Graph Explorer and it worked fine.
I could reproduce the same error message that you're seeing when I used a POST or PUT call from Microsoft Graph Explorer.
Although same request URL with same JSON body worked fine once I changed POST to PATCH. Later on querying the user again (GET), I could see that displayName had been updated correctly

Authenticating to BigQuery REST API via OAuth2 from Node.js

Newbie trying to figure out how to get a Node.js application to authenticate and query Google BigQuery, trying to adapt this CodeLab tutorial from Java. What step might i be missing?
First I create this Oauth2 URL using my clientid:
https://accounts.google.com/o/oauth2/auth?
client_id=1047877053699-den6kbs4v3f2bft6clonsirkj1pc7t6j.apps.googleusercontent.com
&scope=https://www.googleapis.com/auth/bigquery
&redirect_uri=http://localhost:3000/oauth2callback
&access_type=offline
&response_type=code
This successfully reaches Google, which prompts
A third party service is requesting permission to access your Google Account.
Agreeing that generates a second prompt:
Nodejs_Test is requesting permission to:
View and manage your data in Google BigQuery
Agreeing to that, the callback URL is called, with a parameter accessToken.
I think the following url should list tables in my BigQuery project/dataset:
https://www.googleapis.com/bigquery/v2/projects/1047877053699/datasets/visits&accessToken=4%2FC196NizZwlNgWSt5oNqQwendmLNW.0vgUrlGJ6kMRshQV0ieZDApig3NfcgI
But calling with or without the accessToken returns the following message that "Login Required".
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
I know you can't repeat the code because of permissions, expired tokens, etc. But I wonder what step I might be missing conceptually.
Have you tried sending the accesstoken as an authorization header rather than as a url parameter?
as in
https://www.googleapis.com/bigquery/v2/projects/1047877053699/datasets/visits
Authorization: OAuth Your-access-token-here-not-urlencoded
FYI - looks like you originally used the parameter accessToken in the URL. It should instead by access_token, which looks like it works fine. Of course, Jordan's suggestion of using a Header is better if you're able to do it though-- it's more secure as it's unlikely to get logged in access logs, proxy server logs, etc.

Resources