Getting 400 Bad Request Error for MSGraph's create subscription api [Error Code - ExtensionError] - notifications

Trying to create a subscription to get a channel for msgraph one drive notifications for file creation/upload.
I am hitting the URL -
https://graph.microsoft.com/v1.0/subscriptions
with proper headers and the following body -
{
"changeType": "updated",
"notificationUrl": "https://xxxxx.xxxxxxxxx.com/zzzz/qwertqwert",
"resource": "/users/{user-id}/drive/root",
"expirationDateTime": "2017-02-18T19:49:40.000Z",
"clientState": "justsomerandomstring"
}
I am getting the following response :
400 Bad Request Error
{
"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: BadRequest; Reason: Bad Request]",
"innerError": {
"request-id": "2862896286-5415-4921-gbn5-8741288985",
"date": "2017-02-17T17:30:22"
}
}
}
I was making the same request 30-32 hrs back. Was getting the subscription-id as well as the file notifications on my redirection servlet.
Not able to figure out what changed. Couldn't find any helping documentation either

Got the same error here and it took me a while to find out what is the problem so I share this with you here.
Here's the working code:
$subscription = new Subscription([
'resource' => "me/mailFolders('Inbox')/messages?filter=id eq %27" . $draftEmail->getId() . '%27',
'notificationUrl' => 'https://my.domain.fr',
'changeType' => 'updated',
'expirationDateTime' => date(DATE_ISO8601, strtotime('+48 hours'))
]);
The line which was wrong for me is:
'resource' => 'me/messages/' . $draftEmail->getParentFolderId(),
And i replace it with
'resource' => "me/mailFolders('Inbox')/messages?filter=id eq %27" . $draftEmail->getId() . '%27',
I found my answer in this link: https://msdn.microsoft.com/en-us/office/office365/api/notify-rest-operations#subscribe-to-changes-in-my-mail-calendar-contacts-or-tasks
But in my opinion the "resource" parameter should be more documented on graph api documentation and the error message return must specify WHY this is a BadRequest.

Using beta api version solved my problem,
https://graph.microsoft.com/beta/subscriptions

Related

Delete API - TriggerDeleteAPIPipeline.Run failed

I'm currently having problems when trying to delete an API. Basically I followed all steps detailed here: https://cdas.azure.chevron.com/api-and-integration.wiki/API-Products/Delete-API-Utility.html. But when I hit the submit button at the last step It gives me this error here:
TriggerDeleteAPIPipeline.Run failed: { "error": { "code": 502, "source": "msmanaged-na.azure-apim.net", "clientRequestId": "019d9dd4-976f-4bbd-9e4c-aac428af2577", "message": "BadGateway", "innerError": { "error": { "code": "NoResponse", "message": "The server did not receive a response from an upstream server. Request tracking id '08585506028467688679246934075CU94'." } } } }
Any help on how to report this issue? thanks in advance.
I finally got the issue solved. The problem was that I needed to ask for the Personal access token in "full access scope".

Microsoft Graph API Invalid URI: The hostname could not be parsed. when using /search/query

I'm trying to search calendars by name with the v1.0/search/query endpoint from the Graph API. However even I'm trying the examples from the Explorer I get the following error:
{
"error": {
"code": "InternalServerError",
"message": "Invalid URI: The hostname could not be parsed.",
"innerError": {
"date": "2022-03-28T19:50:56",
"request-id": "ddb02afc-1c82-4884-d352-4a8d80809b20",
"client-request-id": "58147981-de34-ba11-ab1f-6e17dca603f9"
}
}
}
Graph Explorer:
Is this endpoint still supported? Is it not allowed for Applications?
From the output we can see that , in the tip its saying for adding the permissions for accessing Calendar events and its API's.
so please try to add those permissions and retry again. Please refer this DOC

How to send multiple Validation Errors to React using Flask and Marshmallow in Backend and Axios for React-Native in Frontend

I am using Marshmallow to validate incoming fields for a simple put request.
Now I am testing the error handling in the frontend to make sure I send the right error messages for the frontend.
I am usually sending data of type
{
password: string,
email: string
}
For now Marshmallow checks if the password is long enough and if the email is of format Email.
I collect all errors in a expect statement and send it to the frontend like this:
except ValidationError as err:
return make_response(
{"errors": err.messages}, status.HTTP_400_BAD_REQUEST
)
with Postman giving me e.g. this response:
{
"errors": {
"email": [
"Missing data for required field."
],
"password": [
"Missing data for required field."
],
}
}
All error messages are therefore collected within the field errors and sent back to the frontend.
When the error is sent back to the frontend I catch my error and all I get is this object:
Object {
"data": null,
"error": [Error: Request failed with status code 400],
}
How do I correctly send or receive the
errors: err.messages
field in the frontend within a make_response error response?
I found the solution to the problem I had here:
github.com/axios/axios/issues/960.
Apparently you have to access the response object or the error object that is send to axios. There is no interceptor needed. What I changed was this line, when resolving the promise to:
try {
resolved.data = await promise;
} catch (e) {
resolved.error = e.response.data;
}
before that I accessed the error with:
try {
resolved.data = await promise;
} catch (e) {
resolved.error = e;
}
The errors are stored within the response.data.

Pushwoosh can not delete message created by API

EDIT: as noted in the answer below, this was a problem on the pushwoosh side, it has been fixed!
When I create a push message through the pushwoosh API (using /createTargetedMessage) I'm not able to delete the message through the API. Messages made with the pushwoosh interface can be deleted through the API, no prob...
These are the steps I took to produce this error:
1. Create push message with the following params
{
"request":{
"auth":"AUTH TOKEN",
"send_date":"2015-09-22 15:07",
"content":{
"nl":"teststsdfgh",
"en":"teststsdfgh"
},
"devices_filter":"A(\"8A1EB-4E875\") * T(\"inholidaypark\", BETWEEN, [\"2015-09-22 00:00\",\"2015-09-22 23:59\"]) * T(\"Language\", IN, [\"nl\", \"en\"])"
}
}
2. This returns the following response; the messageCode is stored in our local DB for later use
{
"status":200,
"response":{
"status_code":200,
"status_message":"OK",
"response":
"messageCode":"D3F6-60769243-68B30EA8"
}
}
}
3. Call /deleteMessage with following data
{
"request":{
"auth":"AUTH TOKEN",
"message": "D3F6-60769243-68B30EA8"
}
}
4. API keeps returning:
{
"status_code": 210,
"status_message": "Message not found",
"response": null
}
But when I look at the push history the message is there (with the same messageCode and all). And it can be deleted through the pushwoosh interface, but not through the API.
On a side note: when the message is sent, we can obviously no longer delete it, then the API returns a more or less correct error:
{
"status_code": 210,
"status_message": "Forbidden",
"response": null
}
Just FYI for the rest of the readers, this issue has been identified and fixed on Pushwoosh side.
Move Along, Nothing to See Here. :)

Fusion table API, INSERT query, bad request

I have a fusion table with fields: username, description,latitude,longitud,geolocation. I am trying to create a new row with information via the google API. I triple checked that the fusion table is open, the tableid and the apikey are correct, and I have the fusiontable API enabled with 0% of the quota. I think the wrong request must be because some coma or quotation mark but to be honest it completely escapes me. I have tried different combinations and cannot find the mistake. Below error that I get, the code that use in php to generate the link and the link itself. Any idea would be greatly appreciated.
Thank you
link returns:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "keyInvalid",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}
Php Code:
$apikey = "AIzaSyB4BMlrZIlJB-Apo8t_dO9K18uL8O2s5TA";
$tableid = "1X0rFoG7Tt2Ocm2rE39wPuamZCrFiS4D32Odgbh03";
$username="webuser";
$description="nujkn";
$latitude="78";
$longitud="110";
$geolocation="98.8789, 150.1111";
$link = "https://www.googleapis.com/fusiontables/v1/query?sql=INSERT+INTO+".$tableid."+(username,description,latitude,longitud,geolocation)+VALUES+('".$username."','".$description."','".$latitude."','".$longitud."','".$geolocation."')&key={".$apikey."}";
Link generated: https://www.googleapis.com/fusiontables/v1/query?sql=INSERT+INTO+1X0rFoG7Tt2Ocm2rE39wPuamZCrFiS4D32Odgbh03+(username,description,latitude,longitud,geolocation)+VALUES+('webuser','nujkn','78','110','98.8789')&key={AIzaSyB4BMlrZIlJB-Apo8t_dO9K18uL8O2s5TA}
which in browser looks like: https://www.googleapis.com/fusiontables/v1/query?sql=INSERT+INTO+1X0rFoG7Tt2Ocm2rE39wPuamZCrFiS4D32Odgbh03+(username,description,latitude,longitud,geolocation)+VALUES+(%27webuser%27,%27nujkn%27,%2778%27,%27110%27,%2798.8789%27)&key={AIzaSyB4BMlrZIlJB-Apo8t_dO9K18uL8O2s5TA}