Microsoft Graph Booking Businesses DELETE operations failing: 404 Http response code - microsoft-graph-api

I am using Postman to successfully create a booking business using a POST method Http request to:
https://graph.microsoft.com/beta/bookingBusinesses.
The request body is like:
{
"DisplayName" : "TEST",
"Email" : "orgmailbox#xxxbuisiness.onmicrosoft.com"
}
The response contains an id.
I am not succeeding when attempting to delete the booking using the REST API here: https://learn.microsoft.com/en-us/graph/api/bookingbusiness-delete?view=graph-rest-beta&tabs=http
The Id use in the DELETE request is that extracted from the response body when the booking business was created.
I get Response code 404 ("Unkown Error").
As per the documentation the registered App in Azure AD has the required Bookings.Manage.All permissions
Does anyone know what might be wrong / how to resolve?

I can reproduce your problem. If you have deleted it, you will get a 404 error when you run the delete again, so please make sure you have deleted it. There may be some delay.
By the way, when you request the api, do not supply a request body for this method, and do not add unnecessary request parameters.
You can use graph-explorer testing.
First delete request:
Second delete request:

The issue we had was due to MFA (Multi-Factor Authentication). When we disabled the requirement for MFA for the user, we were able to successfully make the calls to delete the entry using Postman.

Related

MS Graph API - Get access without a user - Verifying MS response

When using MS-Graph oauth flow "Get Access without a user", Microsoft responds with a GET request of the following structure (from the example in the linked page):
GET https://localhost/myapp/permissions
?tenant=a8990e1f-ff32-408a-9f8e-78d3b9139b95
&state=12345
&admin_consent=True
Is there anyway to verify that the response came from Microsoft?
In our application we're using the state to link an internal tenant-id with the Microsoft tenant-id. If the above response can be forged, an adversary may link his own tenant-id to the victim's Microsoft tenant-id.
You don't really need to check for this step (3) in the doc, because if the admin didn't consent, you would not be able to get an actual token for your app in step 4. However, you might be able to get the Referrer, if it's important to know which page the user came from to get back to your 'https://localhost' page.
You generate something before the redirect, like a guid. Save it on the server, and use it to query the data from before the redirect.
See it as a temporary key that you can set and save in the server memory or in a database.
The state is something you specify before redirecting. And after the admin consent it’s returned to the browser.

Authorization denied for bot when attempting to create conversation via API

I'm trying to develop a bot to be used exclusively for proactive messaging (since unfortunately, it appears Connectors do not support direct messaging). I stood up a web service, and was able to receive the payload from Teams when I sent a message to the bot.
I'm now trying to send a proactive message from the bot back to my user, as described here. Per the instructions, I am POSTing the following payload to <serviceUrl>/v3/conversations. (Values in brackets are interpolated from the payload I received from Teams)
{
"bot": {
"id": <recipient.id>,
"name": <recipient.name>
},
"isGroup": false,
"members": [
{
"id": <from.id>,
"name": <from.name>
}
],
"tenantId": <channelData.tenant.id>,
"topicName": "News Alert"
}
I also included a Bearer token that I got by calling https://login.microsoftonline.com/<channelData.tenant.id>/oauth2/v2.0/token. Yet, whenever I try to create the conversation, it fails with an error that "Authorization has been denied for this request." As far as I can tell, the token should be valid, so I'm not sure what else could be going on here. I saw something about trusting the service URL, but I'm not sure how I would do that since I'm not using the Bot SDK. Perhaps I'm going about this wrong and should be trying to create an Activity rather than a Conversation?
There are basically two steps in sending pro-active messages. The first step is just a once-off - it's getting the unique ID of the conversation between the bot and the user. It's the paragraph you're linking to in your original question, and it's the payload sample you're showing. Once you've got that conversation id, you'd then proceed to sending messages at any time in the future (that's this paragraph).
However, in Teams, the first part is handled differently. Rather than calling the bot framework conversation endpoint (recall that bot framework is used for other things aside from Teams bots), you wait for the user to install the app, which includes your bot. When this is done, your bot will receive a conversationUpdate event. When this fires, you'll be sent a payload which includes the conversationId of the newly-created conversation. This replaces the call you're currently making.
You need to save the conversationId, and the serviceUrl (which will be similar too 'https://smba.trafficmanager.net/apis', but unique for Teams, and will be the 'base' of the URL you'll call later).
Importantly, it is possible to "pre-install" an app for a user, using the Graph API. See Install app for user.
That should help with what you're missing. However, as an 'fyi', you can use libraries for this instead of making the call directly yourself. In dotnet, for instance, you can reference Microsoft.Bot.Connector.ConnectorClient (in Microsoft.Bot.Connector), which has a Conversations.SendToConversationAsync(..) method.
I think I've figured out the problem. I sent my token request to https://login.microsoftonline.com/<channelData.tenant.id>/oauth2/v2.0/token, which was successful and gave me a token back. However, the instructions outlined here say not to use <channelData.tenant.id>, but instead just the hardcoded string botframework.com. After requesting the token that way, my requests appear to be working.

PowerApps Custom Connector returns 404 in app builder

I'm trying to create a connection to an external OData API from PowerApps.
I've created a custom connector via a Postman collection - the custom connector appears to work correctly in test mode but as soon as I try to consume it in the PowerApp I always get a 404 error popup in the expression editor.
Checking the POST request made to https://europe-001.azure-apim.net/invoke and re-playing it with all headers via Postman results in the same 404 error:
{
"statusCode": 404,
"message": "Resource not found"
}
Testing the API in the PowerApps Swagger editor comes back with the results, but instead of a POST to the above URL where headers are sent with the API endpoint address, a GET is made instead.
If I replay this GET request with the same headers etc, I get the same 404. The only thing that changes per request is x-ms-client-request-id so I assume this is to prevent XHR replays.
Am I missing some publishing step for my custom connector?
Has anyone got something like this working?
Edit:
Interestingly - I tried this with a basic API at jsonplaceholder.typicode.com and this works. The API requires no auth and returns data to my Powerapp without an issue.
I'm not sure why this is different from the other custom connector apart from the authentication mechanism.
Edit edit:
This may be a bug in PowerApps - MS support are looking into it for me and another user stated their connectors stopped working since the October release with the same error.

My request URL is not receiving any events for the Slack Events API. What am I missing?

I want to subscribe to Slack Events API for any message posted in a slack channel. These are the following steps I took as given in Slack Event API documentations.
I created a slack app with following permission scopes :
channels:history, groups:history, im:history, mpim:history
In Event Subscriptions, I enabled events, verified Request URL ( "https://api.example.com/slack/event/push") successfully, and subscribed to the following Team Events :
channel_history_changed, group_history_changed, message.channels, message.groups, message.im, message.mpim
I made the user go through oauth authorization to install the app. The url is shown below with scope and redirect uri. (PHP Code)
$url = "https://slack.com/oauth/authorize/?client_id=" . SLACK_CLIENT_ID .
"&scope=users.profile:read,users:read,groups:history,channels:history,im:history,mpim:history" .
"&redirect_uri=" . urlencode('https://api.example.com/slack/oauth/callback') .
"&state=XXXXXXXXX";
I receive a code from slack which I exchange for access token.
Access Token: xoxp-XXXXXXXXX-XXXXXXXXX-XXXXXXX-XXXXXXXXXXXXXXXXXXXX
Scope: identify,channels:history,groups:history,im:history,mpim:history,users:read,users.profile:read
Team Id: XXXXXXXX
I checked the apps and integration of the team to see if the app was installed and yes it is in the list of Apps.
Now as per my understanding when any message is posted in any channel of the team, a POST request should be made to my verified URL ( "https://api.example.com/slack/event/push"). But I don't get any POST request there.
I thought maybe the URL is broken but I tested it with a counter and every time the URL is hit it increments the counter. So the URL is fine.
Is there a step I missed somewhere? I don't know what to try next.
I contacted Slack support and they were very helpful. The logs at slack showed that Slack was actually sending POST requests to my Request url. So my setup worked fine. But my API framework was failing to parse the request body and hence sending internal server error (500) to Slack. We figured this out by using requestb.in.
All I had to do was change the way I parsed request body.
Having the channel be public is VERY important!

Instagram oauth api gives { "code": 400, "error_type": "OAuthException", "error_message": "No matching code found." }

I am working on an application that integrates with Instagram API to access the user information. I successfully fetch the Access Token using the authorize url but unable to fetch the userId using access_token url:
i am tried both the endpoints:
https://api.instagram.com/oauth/access_token?client_id=48275564e2c445f6b8e1356djfha3e0c&client_secret=ab2062da9f314e3489dke7ae9cbe6e5d&redirect_uri=http://localhost&grant_type=authorization_code
https://api.instagram.com/oauth/access_token
with the post body as:
client_id=48275564e2c445f6b8e1356djfha3e0c&client_secret=ab2062da9f314e3489dke7ae9cbe6e5d&redirect_uri=http://localhost&grant_type=authorization_code&code=1351860224.4827556.5dc92c4d15ea4a4ea1b0d33eaf0eef19
(The data in the request is modified), But i am getting the follwing
{
"code": 400,
"error_type": "OAuthException",
"error_message": "No matching code found."
}
I have seen tons of queries and questions but could not find any solution to the problem.
The couple of questions i have is:
1) is the field code in the URL is same as access_token, if not how could i get the code field's value.
2) is there any other mechanism(API) to fetch the user details given the username is not known.
Please help me as i am completely stuck and running out my deadlines.
For me unchecking Disable implicit OAuth in instagram developer -> manage clients fixed the issue
I found that using either form-data or application/x-www-form-urlencoded works fine. The most important is the code you get from redirect uri is only used by one request. It means you could request the access token once for the code. If the you request more than one time with same code, you'll get the error like this:
{
code: 400,
error_type: "OAuthException",
error_message: "Matching code was not found or was already used."
}
Wish you all the best ;)
Try to urlEncode the redirect_uri param to
http%3A%2F%2Flocalhost
And your code param contains the "." character which might be a error.
code=1351860224.4827556.5dc92c4d15ea4a4ea1b0d33eaf0eef19
might caused the problem
"error_message": "No matching code found."
"5dc92c4d15ea4a4ea1b0d33eaf0eef19" seems to be the correct code
I got same error. It seems that instagram's spam system disable user's access to any non-official application. Just change user's password. In my case it was help.
Also try create another application.
UPD
From my answer to another question
It looks like users get more than one code, and you see first code, but need second. Try relogin users, if you gets error. User will not see instagram page with confirm button, just redirections.
Possible algorithm of error:
1. User click auth link.
2. Get first code.
3. User click auth link (twice, redirection problem, public auth system, etc.)
4. Get another code (even on the same client_id, redirect_uri).
5. You get first code.
6. But first code already doesn't exists.
The problem is here that need redirect url set as http://localhost/signin-instagram
signin-instagram part is very important
So go to Instagram.com/developer ->Manage Client-> Security -> Valid redirect URIs set with that end http:/../signin-instagram
Off late instagram python snippet fails due to missing content-type HTTP header
response, content = http_object.request(url, method="POST", body=data,headers = {"Content-type": "application/x-www-form-urlencoded"})
adding application/x-www-form-urlencoded worked for me
I will mention what worked for me.
Step 1. Generate a new client secret from you panel.
Step 2. Follow the step 1 mentioned here to obtain the code again.
Step 3. Send the request again with the changed parameters.
Make sure you are logged in the browser when you send the request. You will get the required response.
Go into Facebook for Developers > Your app. Click on "Roles" and add an Instagram test-account under "Instagram Testers".
Log into instagram.com and go to: Settings > Security > Apps and Websites, where you will accept the test invitation.
Prepare your URL link, which you will paste into the web browser. Make sure to use a valid redirect URI from "Valid OAuth Redirect URIs" from the Instagram Basic Display settings.
If you did everything right, the Instagram tester account for the app, will have the option to gain access to user_profile,user_media. Continue the process to get the code which you can exchange for a short-lived access token.

Resources