Unable to access Google Plus API in browser - ios

i am working on to display wall posts (Stream) data using Google Plus API.
i have valid Client ID + API_KEY.
I am able to get response from Google Plus cloud console.i.e. by executing method I get Something like
Request
GET https://www.googleapis.com/plus/v1/people/myuserid/activities/public?maxResults=5&key={YOUR_API_KEY}
X-JavaScript-User-Agent: Google APIs Explorer
Response
200 OK
Show headers -
{
"kind": "plus#activityFeed",
"etag": "\"Mwea3qudNDf-hWWlPWi3n-YrU1Q/ovxXa0lmTRbwzkDa9o_iJ2pdFBs\"",
"nextPageToken": "CAIQgIi2z8bDugIgASgB",
"title": "Google+ List of Activities for Collection PUBLIC",
"updated": "2013-11-01T12:07:44.665Z",
"items": [
{
"kind": "plus#activity",
"etag": "\"Mwea3qudNDf-hWWlPWi3n-YrU1Q/JdSanh1QlMQ72Ubbabsiz2rP4B8\"",
"published": "2013-11-01T12:07:44.665Z",
"updated": "2013-11-01T12:07:44.665Z",
"id": "id",
"url": "https://plus.google.com/userid/posts/bYSPSVjXCXL",
"actor": {
"id": "116100754354787768146",
"displayName": "name",
"url": "https://plus.google.com/userid",
"image": {
"url": "someurl"
}
},
"verb": "post",
"object": {
"objectType": "note",
"content": "",
"url": "https://plus.google.com/userid/posts/bYSPSVjXCXL",
"replies": {
"totalItems": 1,
"selfLink": "https://content.googleapis.com/plus/v1/activities/z13xulwx3qjuxnkii04cjpsqgsjlyp2j23o/comments"
},
}
........
Seems good till now..but,when i use Request URL i.e https://www.googleapis.com/plus/v1/people/myuserid/activities/public?maxResults=5&key={MY_API_KEY} i got something from browser like this
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured"
}
],
"code": 403,
"message": "Access Not Configured"
}
}
where i am going wrong ?! how to get correct response from Browser. ? as i want to parse them and use these data in my Application.
NOTE: Google + API is ON.

Are you making sure that you have replaced {MY_API_KEY} with the API key that you have generated using the Cloud Console?

Are you using the Browser Key? It works OK for me.

Related

Enumerate DriveItem resources of a specific Drive given SharePoint URL and using Graph API

I have a SharePoint URL of the form https://organizationname.sharepoint.com/sites/....
I want to use the Graph API to get a list of all resources in this drive. Reading the API documentation it appears that I require the drive-id of this drive in order to perform this request.
/drives/{drive-id}/root/children
Also, according to the answer to a similar stackoverflow question it appears there are no APIs to convert SharePoint URL to OneDrive driveId. Is there a possible workaround? Is there any way to programmatically get a list of resources from a SharePoint URL?
If your SharePoint URL is https://organizationname.sharepoint.com/sites/yourSiteName, then you can issue a request like this via the Graph API (scope Sites.Read.All might be required):
client.api("/sites/organizationname.sharepoint.com:/sites/yourSiteName:/drives").get();
That request will return something like this:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
"value": [
{
"createdDateTime": "2021-07-24T23:35:00Z",
"description": "",
"id": "b!A1234567-ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210",
"lastModifiedDateTime": "2021-08-12T16:39:23Z",
"name": "Dokumente",
"webUrl": "https://organizationname.sharepoint.com/sites/yourSIteName/folderName",
"driveType": "documentLibrary",
"createdBy": {
"user": {
"displayName": "abc"
}
},
"lastModifiedBy": {
"user": {
"email": "bla#organizationame.onmicrosoft.com",
"id": "12345678-4321-4321-4321-012345678901",
"displayName": "zz"
}
},
"owner": {
"group": {
"email": "x#y.onmicrosoft.com",
"id": "09876543-1234-1234-1234-012345678901",
"displayName": "Owner of something"
}
},
"quota": {
"deleted": 345678,
"remaining": 27487788453406,
"state": "normal",
"total": 27487790694400,
"used": 96120
}
}
]
}
The id under description is the drive-id. With that you can get /root/children like so:
client.api("/sites/yourorganizationname.sharepoint.com/drives/b!A1234567-ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210/root/children").get();
While there is no single API or algorithm that allows you to programmatically get a list of resources from a SharePoint URL, you can achieve the same with two Graph API requests.

Is there a way to post a message with a code snippet?

The new way to upload images as hosted content through the Send Message endpoint is great! However, is there a way to upload text/plain as hosted content in order to post a Code Snippet Card in a message?
I have tried uploading text but the response gives me an error that says that the only content types allowed are 'image/jpg,image/jpeg,image/png'.
Example request:
{
"body": {
"contentType": "html",
"content": "<attachment id=\"4d92eb51ab9c48ebb5b364794a2fa569\"></attachment>"
},
"attachments": [
{
"id": "4d92eb51ab9c48ebb5b364794a2fa569",
"contentType": "application/vnd.microsoft.card.codesnippet",
"contentUrl": null,
"content": "{\"name\":\"\",\"language\":\"CSharp\",\"lines\":1,\"wrap\":false,\"codeSnippetUrl\":\"../hostedContents/1/$value\"}",
"name": null,
"thumbnailUrl": null
}
],
"hostedContents":[
{
"#microsoft.graph.temporaryId": "1",
"contentBytes": "VGVzdA==",
"contentType": "text/plain"
}
]
}
Response:
{
"error": {
"code": "BadRequest",
"message": "Unsupported content type in hostedContent with Id '1'. Allowed values are 'image/jpg,image/jpeg,image/png'",
"innerError": {
"date": "2020-10-07T12:17:15",
"request-id": "ed24f5df-3e1f-4871-b430-e4c1c9f30348",
"client-request-id": "ed24f5df-3e1f-4871-b430-e4c1c9f30348"
}
}
}
I received an answer in the Documentation GitHub: https://github.com/microsoftgraph/microsoft-graph-docs/issues/10210#issuecomment-705050649
Code snippets are not supported at the moment. They are on list of things to support, but there is no timeline to share yet.

Unable to retrieve event details using Microsoft Graph API 1.0

Has anyone got Microsoft Graph API working for EventMessage? i.e reading email content of EventMessage using Graph API.
Looks like it has actionable card and graph API 1.0 is not able to read it.
Provided delegate access to user for a room resource.
On event creation for that room, mail is received by the delegated user in inbox. The mail type is eventMessage ("#odata.type": "#microsoft.graph.eventMessage").
On fetching the mail through GraphAPI v1.0, the event values are not visible in the response.
Also on setting the Expand property for the mail in graph API as per docs, results in below error.
{ "error": {
"code": "BadRequest",
"message": "Parsing Select and Expand failed.",
"innerError": {
"request-id": "310bbcce-bdd8-4cb6-890c-035243a5ab6d",
"date": "2020-01-21T09:18:10"
}
}
}
I'm unable to repro your issue. The Microsoft Graph API returns details for event messages. Can you provide repro steps, request/response capture, and the values that you'd expect to see?
I used v1.0/me/messagesto get all of the messages to find an eventMessage. I then perform the following to get details on the eventMessage:
GET https://graph.microsoft.com/v1.0/me/messages/{messagedId}
Response body:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('d09-94-498-a9777d4b')/messages/$entity",
"#odata.type": "#microsoft.graph.eventMessage",
"#odata.etag": "W/\"DAA2pU9s\"",
"id": "AAMkADEzOTExYjJkAAA=",
"createdDateTime": "2020-01-24T14:47:24Z",
"lastModifiedDateTime": "2020-01-24T21:08:07Z",
"changeKey": "DApU9s",
"categories": [],
"receivedDateTime": "2020-01-24T14:47:25Z",
"sentDateTime": "2020-01-24T14:47:11Z",
"hasAttachments": false,
"internetMessageId": "<AM5P3M#A38.EURPRD83.prod.outlook.com>",
"subject": "Accepted: Microsoft Graph DevX Roadmap",
"bodyPreview": "",
"importance": "normal",
"parentFolderId": "AAMk3AAA=",
"conversationId": "AAQkADEzOU4=",
"conversationIndex": "AdXReVPepTg==",
"isDeliveryReceiptRequested": null,
"isReadReceiptRequested": false,
"isRead": true,
"isDraft": false,
"webLink": "https://outlook.office365.com/owa/?ItemID=AAMkA%3D&exvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification": "focused",
"meetingMessageType": "meetingAccepted",
"body": {
"contentType": "text",
"content": ""
},
"sender": {
"emailAddress": {
"name": "Nicole",
"address": "sig#contoso.com"
}
},
"from": {
"emailAddress": {
"name": "Nicole",
"address": "sig#contoso.com"
}
},
"toRecipients": [
{
"emailAddress": {
"name": "Michael Mainer",
"address": "mm#contoso.com"
}
}
],
"ccRecipients": [],
"bccRecipients": [],
"replyTo": [],
"flag": {
"flagStatus": "notFlagged"
}
}

Microsoft Graph API group folder invite response is wrong

I have been trying to grant a single user (possibly outside of the organization) access to a folder used by a shared group in Share Point The Microsoft Graph Docs state that the response should have an Id in it.
If I use a personal oneDrive account, and make the following request:
POST v1.0
https://graph.microsoft.com/v1.0/groups/{groupId}/drive/items/{folderId}/invite
body: {
"requireSignIn": true,
"sendInvitation": true,
"roles": [ "read"],
"recipients": [
{ "email": "{myPersonalEmail}" },
],
"message": "testing giving permission to self"
}
I get the following response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(permission)",
"value": [
{
"#odata.type": "#microsoft.graph.permission",
"id": "{permissionID}",
"roles": [
"read"
],
"grantedTo": {
"user": {
"email": "{myPersonalEmail}",
"id": "{responseID}",
"displayName": "Sarah"
}
}
}
]
}
However, we setup a different SharePoint account that when I make the same request https://graph.microsoft.com/v1.0/groups/{groupId}/drive/items/{folderId}/invite
I get a completely different response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(permission)",
"value": [
{
"#odata.type": "#microsoft.graph.permission",
"roles": [
"read"
],
"invitation": {
"signInRequired": true
},
"link": {
"type": "view",
"webUrl": "{shareURL}"
}
}
]
}
This is so bizarre to me, because we are hitting the same endpoint. It makes me think that maybe there are some site configurations that are making these two responses differ.
Does anyone know why we would be getting a different results from the same endpoint?

Twitter ads API "GET /1/stats/accounts/:account_id" unauthorized access

I am using postman APP for accessing GET request through TWITTER API. Though I am able to generate output through all other GET and POST request through OAUTH 1.0. But when I am sending the request through "GET /1/stats/accounts/:account_id" method, its generating the following error.
{
"errors": [
{
"code": "UNAUTHORIZED_ACCESS",
"message": "This request is not properly authenticated"
}
],
"request": {
"params": {}
}
}
I am using the following request : "https://ads-api.twitter.com/1/stats/accounts/:18ce53yh9sw?entity_ids=88hjg&entity=CAMPAIGN&end_time=2017-05-14T17:00:00Z&granularity=HOUR&metric_groups=BILLING&placement=ALL_ON_TWITTER&start_time=2017-05-05T15:00:00Z"
This is the most important GET request for me to get the campaign level data. Any other way around may be helpful.
UPDATE:
The following request is working for https://ads-api.twitter.com/1/accounts/:account_id
{
"request": {
"params": {}
},
"data": [
{
"name": "Wadi.com",
"business_name": null,
"timezone": "Asia/Riyadh",
"timezone_switch_at": "2013-05-21T21:00:00Z",
"id": "18ce53yh9sw",
"created_at": "2015-03-12T07:33:09Z",
"salt": "0f034423fa35f95e8efc844a25c4d7a3",
"updated_at": "2017-05-17T06:03:58Z",
"business_id": null,
"approval_status": "ACCEPTED",
"deleted": false
}
],
"data_type": "account",
"total_count": 1,
"next_cursor": null
}
Regards
Shree Kant

Resources