Failed to add a new subscription for my own onedrive 'Documents' folder - onedrive

I have failed to add a new subscription webhook URL for my personal one drive Documents folder ( not a business account). The request response details is as follows.
URL: https://graph.microsoft.com/v1.0/subscriptions
Try 1
Request JSON:
{
"notificationUrl": "https://****.rest/OneDrive/newItemWebhook",
"expirationDateTime": "2017-09-18T11:23:00.000Z",
"resource": "/me/drive/root/Documents",
"changeType": "updated",
"clientState": "client-specific string"
}
Response JSON:
{
"error": {
"code": "BadRequest",
"message": "Unsupported segment type. ODataQuery:
users/****#outlook.com/drive/root/Documents",
"innerError": {
"request-id": "169755ee-bdf5-460e-8577-6f1e22777207",
"date": "2017-09-18T10:46:07"
}
}
}
Try 2
Request JSON:
{
"notificationUrl": "https://****.rest/OneDrive/newItemWebhook",
"expirationDateTime": "2017-09-18T11:23:00.000Z",
"resource": "/me/drive/root:/Documents",
"changeType": "updated",
"clientState": "client-specific string"
}
Response JSON:
{
"error": {
"code": "InvalidRequest",
"message": "resource '/me/drive/root:/Documents' is not supported.",
"innerError": {
"request-id": "403229b0-0554-46c2-82b8-ede69a4ef9a2",
"date": "2017-09-18T10:50:36"
}
}
}
In both cases the cases the failed to add subscription webhook URL but the reason in unknown to me, means what is :
Unsupported segment type. ODataQuery
resource '/me/drive/root:/Documents' is not supported.
and then if I want to set webhook URL for the above mention "resource" then what will be the path for my case!

Apparently, you cannot subscribe to changes in the particular folder, but to a drive, so you should subscribe to /me/drive/root. Then you could use driveitem delta api to track changes: https://learn.microsoft.com/en-gb/onedrive/developer/rest-api/api/driveitem_delta or use your own method (i.e. list files in the Documents folder)
Here is a bit outdated video explaining the process: https://channel9.msdn.com/Events/Build/2016/P566

Related

Bad Request: One or more of the contents is not owned by the author. All contents must be owned by the author

I've been trying to POST an image to linkedin via the API given by linkedin: https://api.linkedin.com/v2/ugcPosts
Here are some of the steps I followed according to their documentation:
Step 1: Register the image,
Response I get:
{
"value": {
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C4D22AQHnSETazVUUiw,urn:li:digitalmediaMediaArtifactClass:feedshare-uploadedImage)",
"uploadMechanism": {
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest": {
"uploadUrl": "https://api.linkedin.com/mediaUpload/C4D22AQHnSETazVUUiw/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQKy8KTj9ZExhAAAAYUvD_6GEclpKOZdwJvPF682Ld1UUb6h0V7VvAtpuA&app=206373578&sync=0&v=beta&ut=3dh6EETZGM5WA1",
"headers": {
"media-type-family": "STILLIMAGE"
}
}
},
"asset": "urn:li:digitalmediaAsset:C4D22AQHnSETazVUUiw",
"assetRealTimeTopic": "urn:li-realtime:digitalmediaAssetUpdatesTopic:urn:li:digitalmediaAsset:C4D22AQHnSETazVUUiw"
}
}
Step 2: Upload the image using upload URL from Step 1
Response: 201 Created status code with no message
Checked the status, it's says available: https://api.linkedin.com/v2/assets/C4D22AQHnSETazVUUiw
{
"recipes": [
{
"recipe": "urn:li:digitalmediaRecipe:feedshare-image",
"status": "AVAILABLE"
}
],
"serviceRelationships": [
{
"relationshipType": "OWNER",
"identifier": "urn:li:userGeneratedContent"
}
],
"mediaTypeFamily": "STILLIMAGE",
"created": 1671531855410,
"id": "C4D22AQHnSETazVUUiw",
"lastModified": 1671531901231,
"status": "ALLOWED"
}
Now when I am trying to POST it to the endpoint: https://api.linkedin.com/v2/ugcPosts
It's giving 400 bad Request with the following Error:
{
"errorDetailType": "com.linkedin.common.error.BadRequest",
"message": "com.linkedin.content.common.exception.BadRequestResponseException: One or more of the contents is not owned by the author. All contents must be owned by the author",
"errorDetails": {
"inputErrors": [
{
"description": "Content(s) you provided must be owned by post author",
"input": {},
"code": "INVALID_CONTENT_OWNERSHIP"
}
]
},
"status": 400
}
I've given all permissions to it:
r_emailaddress, r_liteprofile, w_member_social

Why doesn't GraphQL.NET honour the errors.extensions schema?

I recently rewrote some GraphQL services from Java to .NET Core.
In Java, I was able to provide custom error messages to the clients using the errors.extensions in the response, ie:
{
"data": {
"someMutation": null
},
"errors": [{
"cause": null,
"message": "Unauthorized",
"httpStatusCode": 0,
"extensions": {
"uiMessage": "Oh no, your session expired. You'll need to login again to continue.",
"httpStatusDescription": "Unauthorized",
"httpStatusCode": 401
},
"errorType": "ValidationError",
"path": null,
"localizedMessage": "Unauthorized",
"suppressed": []
}
]
}
However, in .NET, I don't seem to be able to replicate this format.
ErrorInfo.Extensions is added to the root of the response, not to the the Errors object itself, eg:
{
"data": {
"someMutation": null
},
"errors": [{
"message": "Auth token not provided"
}
],
"extensions": {
"httpStatusCode": 401,
"httpStatusDescription": null,
"uiMessage": "Oh no, your session expired. You'll need to login again to continue.",
}
}
The GraphQL spec reads (ref https://spec.graphql.org/October2021/#sec-Errors, https://spec.graphql.org/October2021/#example-8b658):
GraphQL services may provide an additional entry to errors with key
extensions. This entry, if set, must have a map as its value. This
entry is reserved for implementors to add additional information to
errors however they see fit, and there are no additional restrictions
on its contents.
eg:
{
"errors": [
{
"message": "Name for character with ID 1002 could not be fetched.",
"locations": [{ "line": 6, "column": 7 }],
"path": ["hero", "heroFriends", 1, "name"],
"extensions": {
"code": "CAN_NOT_FETCH_BY_ID",
"timestamp": "Fri Feb 9 14:33:09 UTC 2018"
}
}
]
}
I created a new test project (.NET Core 3.1) using the latest versions of the libraries (GraphQL 7.1.1 et al) but am still unable to add custom properties to errors.extensions.
This is the test mutation which intentionally throws an exception:
Field<StringGraphType>("greet")
.Argument<NonNullGraphType<StringGraphType>>("name")
.Resolve(context => {
try {
throw new Exception("Invalid input");
return "Hello " + context.GetArgument<String>("name");
} catch(Exception ex) {
// This doesn't seem to get returned anywhere in the response
Dictionary<String, object> extraData = new Dictionary<string, object>();
extraData.Add("error1", "message1");
// Add the error to the response using the overloaded constructor
context.Errors.Add(new ExecutionError("Oh dear, that went wrong", extraData));
// This gets added to the root of the response
context.OutputExtensions.Add("error2", "message2");
return null;
}
});
the mutation to invoke it:
mutation {greet(name:"Chewbacca")}
and the response (I don't know where errors.extensions.details comes from):
{
"errors": [
{
"message": "Oh dear, that went wrong",
"extensions": {
"details": "GraphQL.ExecutionError: Oh dear, that went wrong"
}
}
],
"data": {
"greet": null
},
"extensions": {
"error2": "message2"
}
}
I would imagine that the GraphQL.NET library would expose an Extensions dictionary on the ExecutionError object so one could add custom values in the usual manner, eg:
ExecutionError executionError = new ExecutionError("Oh dear, that went horribly wrong");
executionError.Extensions.Add("customError", "Your custom error here")
context.Errors.Add(executionError);
Which would result in a response similar to this:
{
"data": {
"someMutation": null
},
"errors": [{
"message": "Oh dear, that went horribly wrong",
"extensions": {
"customError": "Your custom error here"
}
}
]
}
I am hopeful that some bright individual in the community can (slap me upside the head and) point me in the right direction.

Why is my whatsapp message not being sent?

Testing with Postman, I'm trying to send a message per the glitch example project from docs
I'm trying to write an API endpoint I can hit with a webhook when people send a message to my Org's whatsapp number. The API would send an automated response.
When I send the POST, with the following body to https://graph.facebook.com/v14.0/redacted/messages it comes back with the following response:
{
"error": {
"message": "(#131030) Recipient phone number not in allowed list",
"type": "OAuthException",
"code": 131030,
"error_data": {
"messaging_product": "whatsapp",
"details": "Recipient phone number not in allowed list: Add recipient phone number to recipient list and try again."
},
"error_subcode": 2655007,
"fbtrace_id": "A5YKQbpB0PEaaA-gIROEv-n"
}
}
The error code isn't list one the error codes page, nor can I find anything about adding a recipient phone number anyway (it doesn't make sense to require a pre-defined list of recipient phone numbers to which I can send messages).
Here's the message body:
{
"messaging_product": "whatsapp",
"to": "redacted",
"text": {
"body": "Ack: Hello world"
}
}
How do I get the message sent? I'm not able to proceed with development of my app until I can send a message.
Just Remove + from your mobile number and add you country code before your number.
Then its working fine.
Request Body:
{
"messaging_product": "whatsapp",
"to": "91xxxxxxxxxx",
"type": "template",
"template": {
"name": "hello_world",
"language": {
"code": "en_US"
}
}
}
Response Body:
{
"messaging_product": "whatsapp",
"contacts": [
{
"input": "91xxxxxxxxxx",
"wa_id": "91xxxxxxxxxx"
}
],
"messages": [
{
"id": "wamid.HBgMOTE3NTM4OTE4MzIyFQIAERgSOERCM0ZDOTJFMDk1RjBFNURBAA=="
}
]
}
for Your Reference
I got the same error code and message here.
I was debugging it and see that the from number is a little different than the number I had registered when I will echo the message back.
You can put the number of phone hard coded that you have registered before to see it working.

INVALID_ARGUMENT error with Google Analytics Reporting API

I'm trying to do a request to the userActivity.search method,
this is the payload that I'm trying to do:
{
"viewId": "<VIEW ID>",
"dateRange": {
"startDate": "7daysAgo",
"endDate": "today"
},
"user": {
"type": "CLIENT_ID",
"userId": "<USER ID>"
}
}
But I'm stuck getting this error:
{
"error": {
"code": 400,
"message": "CLIENT_ID: <ID> not found.",
"status": "INVALID_ARGUMENT"
}
}
The ClientId I get previously at other GA endpoint that list the ClientIds that I need to get more details.
What am I doing wrong?

Invalid Path error while inserting job from google cloud storage to google bigquery

I am trying to insert a job through HTTP Post request, but i am getting Invalid path error.
My request body is as follows:
{
"configuration": {
"load": {
"sourceUris": [
"gs://onianalytics/PersData.csv"
],
"schema": {
"fields": [
{
"name": "Name",
"type": "STRING"
},
{
"name": "Age",
"type": "INTEGER"
}
]
},
"destinationTable": {
"datasetId": "Test_Dataset",
"projectId": "lithe-anvil-404",
"tableId": "tb_test_Pers"
}
}
},
"jobReference": {
"jobId": "10",
"projectId": "lithe-anvil-404"
}
}
For the sourceuri parameter, I am passing "gs://onianalytics/PersData.csv", where onianalytics is my bucket name and PersData.csv is my csv file (from which I want to upload data into google bigquery).
I am getting below response:
"status": {
"state": "DONE",
"errorResult": {
"reason": "invalid",
"message": "Invalid path: gs://onianalytics/PersData.csv"
},
"errors": [
{
"reason": "invalid",
"message": "Invalid path: gs://onianalytics/PersData.csv"
}
]
},
"statistics": {
"creationTime": "1387276603674",
"startTime": "1387276603751",
"endTime": "1387276603751"
}
}
My bucket is under the same projectid which has the BigQuery service activated. Also, I have Google Cloud Storage enabled under APIs and Auth. Following scopes are added while authenticating:
googleapis.com/auth/bigquery, googleapis.com/auth/cloud-platform, googleapis.com/auth/devstorage.full_control,googleapis.com/auth/devstorage.read_only,googleapis.com/auth/devstorage.read_write
I am inserting this job by "Try it!" link which is available on developers.google.com/bigquery/docs/reference/v2/jobs/insert.
In fact I am able to create buckets and objects in goggle cloud storage through APIs. But when i try to insert job from the uploaded object (which is a csv file), i got "Invalid Path" error. Can anyone please help me to identify why this error is occurring?
The error I get when trying the code above is "Not found: URI gs://onianalytics/PersData.csv".
I'm wondering if instead of /onianalytics/ you had a different path with invalid characters?