YouTube API subscription insert always returns an error - google-api

How to Add a subscription for the authenticated user's channel
https://www.googleapis.com/youtube/v3/subscriptions?part=snippet&key={YOUR_API_KEY}
Request Parameters :-
{
"0":
{ "name": " <code>snippet.resourceId.kind</code>", "value": "youtube#channel" },
"1": { "name": " <code>snippet.resourceId.channelId</code>", "value": "UC_x5XG1OV2P6uZZ5FSM9Ttw" }
}
Response Parameters :-
{
"error":
{ "errors":
[ { "domain": "youtube.subscription", "reason": "publisherRequired", "message": "The subscription resource specified in the request must use the <code>snippet.resourceId</code> property to identify the channel that is being subscribed to." } ], "code": 400, "message": "The subscription resource specified in the request must use the <code>snippet.resourceId</code> property to identify the channel that is being subscribed to." }
}

This apears to be a bug in the Youtube api. this can be verifyed by checking the api explorer here .
POST https://www.googleapis.com/youtube/v3/subscriptions?part=snippet&key={YOUR_API_KEY}
{
"0": {
"name": "snippet.resourceId",
"value": "youtube#channel"
},
"1": {
"name": "snippet.resourceId",
"value": "UC_x5XG1OV2P6uZZ5FSM9Ttw"
}
}
Response
{
"error": {
"errors": [
{
"domain": "youtube.subscription",
"reason": "publisherRequired",
"message": "The subscription resource specified in the request must use the <code>snippet.resourceId</code> property to identify the channel that is being subscribed to."
}
],
"code": 400,
"message": "The subscription resource specified in the request must use the <code>snippet.resourceId</code> property to identify the channel that is being subscribed to."
}
}
There is an issue request for this issue and the team has been pinged.

Link of Youtube Data API (V3), you can try here
it's the image example in "try this API" of how i do
POST https://www.googleapis.com/youtube/v3/subscriptions?part=snippet HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Content-Type: application/json
{
"snippet": {
"resourceId": {
"kind": "youtube#channel",
"channelId": "UCUK0HBIBWgM2c4vsPhkYY4w"
}
}
}

Related

400 Error in People API [people.updateContact ]

400 Error in People API [people.updateContact]
I'm need updateContact field locations of user in g-suite
i get 400 error "Resource name "people/{xxxxxxx}" is not a valid contact person resource."
request
{
"resourceName": "people/xxxxxxxxxxx",
"etag": "xxxxxxxxxxxxxx",
"locations": [
{
"metadata": {
"primary": true,
"source": {
"type": "PROFILE",
"id": "xxxxxxxxxxxxxxxx"
}
},
"value": "TestA",
"current": true
},
{
"metadata": {
"source": {
"type": "PROFILE",
"id": "xxxxxxxxxxxxxxxxx"
}
},
"value": "TestB"
}
]
}
response
{
"error": {
"code": 400,
"message": "Resource name \"people/{xxxxxxx}\" is not a valid contact person resource.",
"status": "INVALID_ARGUMENT"
}
}
Answer:
The error "Resource name \"people/{xxxxxxx}\" is not a valid contact person resource." appears because the resource name you are providing in your request is not a valid contact person resource.
Fix:
Replace people/{xxxxxxx} with a valid resource. You can obtain these using people.listDirectoryPeople endpoint.

"Requested entity was not found" when writing on Google Home Graph

I'm trying to update the state of a device using Google Home Graph API, but I'm getting this reply and I don't understand why:
{
"error": {
"code": 404,
"message": "Requested entity was not found.",
"status": "NOT_FOUND"
}
}
This is the first part of my SYNC reponse:
{
"requestId": "reqId",
"payload": {
"agentUserId": "myAgentUserId",
"devices": [
{
"id": "myDeviceId",
...
}
and this is what I'm sending to
https://homegraph.googleapis.com/v1/devices:reportStateAndNotification
{
"agentUserId": "myAgentUserId",
"payload": {
"devices": {
"states": {
"myDeviceId": {
"on": true
...
}
As you can see, both myAgentUserId and myDeviceId in Home Graph's request are the same to the ones returned to the SYNC request.
What am I doing wrong?

How to use Gmail API without raw attribute in JSON

I'm try to send email using google gmail API. I've used Request body JSON with bearer token and Content-Type - message/rfc822.
Then I've used link below to send post request but I received the following errors.how to fix this issue ???
Post request Link -
https://www.googleapis.com/upload/gmail/v1/users/kasunysoft#gmail.com/messages/send
Request Body
{
"threadId": "Hi kasunjith",
"payload": {
"mimeType": "message/rfc822",
"headers": [
{
"name": "To",
"value": "hvn#gmail.com"
},
{
"name": "From",
"value":"kasunysoft#gmail.com"
},
{
"name":"Subject",
"value":"Subject Text"
}
]
}
}
I got response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Recipient address required"
}
],
"code": 400,
"message": "Recipient address required"
}
}
This means that your format in sending email is not valid. Check the documentation for Users.messages and Users.messages: send for the proper format.
{
"id": string,
"threadId": string,
"labelIds": [
string
],
"snippet": string,
"historyId": unsigned long,
"internalDate": long,
"payload": {
"partId": string,
"mimeType": string,
"filename": string,
"headers": [
{
"name": string,
"value": string
}
],
"body": users.messages.attachments Resource,
"parts": [
(MessagePart)
]
},
"sizeEstimate": integer,
"raw": bytes
}
You can also check out the following SO post for more in depth discussion about you error.
400 error. Recipient address required. JavaScript
How to send a message successfully using the new Gmail REST API?

What is the Json response we should send to microsoft botFramework to route my response to telegram channel

I am sending below response to the service url provided by botFramework request https://telegram.botframework.com/v3/conversations/-263387177/activities/
My intent is that using sendMessage method of telegram I am able to route a text to the telegram channel via microsoft botframework
The http post which I am sending is as below
{
"type": "message",
"locale": "en-Us",
"chat_id":-263387177,
"channelID":"telegram",
"from": {
"id": "GTSFIBot",
"name": "sapeops"
},
"text":"hi , Greetings!",
"replyToId": "1505813737353",
"recipient": {
"id": "DirectLineClient"
},
"conversation": {
"isGroup": true,
"id": "-263387177",
"name": "sapeops group"
},
"channelData": {
"method": "sendMessage",
"parameters": {
"chat_id": -263387177,
"parse_mode": "HTML",
"text": "<B>Greetings! How are you doing?</B>"
},
"chat": {
"id": -263387177,
"title": "sapeops group",
"type": "group",
"all_members_are_administrators": true
}
}
}
I get 502 bad gateway response and a below JSON.
{
"error": {
"code": "ServiceError",
"message": "Telegram API returned a result code indicating non-success"
}
}

Skype/MS Team REST API not working

I'm creating a bot using REST API. Indeed, I want to send a message from my bot to me as following
I start with 'Authentification'
Request:
curl -k -X POST https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token -d "grant_type=client_credentials&client_id={app_id}&client_secret={app_password}&scope=https://graph.microsoft.com/.default"
Response:
{
"token_type": "Bearer",
"expires_in": 3599,
"ext_expires_in": 0,
"access_token": "<access_token>"
}
Next, I start a new conversation
Request:
POST https://skype.botframework.com/v3/conversations
Authorization: Bearer <access_token>
Content-Type: application/json
{
"bot": {
"id": "standupalice",
"name": "Standup Alice"
},
"isGroup": false,
"members": [
{
"id": "<my bot id>",
"name": "Standup Alice"
},
{
"id": "<my user id>",
"name": "Bao"
}
],
"topicName": "News Alert"
}
NOTE: and are obtained from a callback message sent from Skype app to Standup Alice bot.
Response:
{
"id": "<conversation id>"
}
It's weird since the conversation ID is identical to . Well, now I compose a message to send to me as following
Request:
POST https://skype.botframework.com/v3/conversations/<conversation id>/activities
Authorization: Bearer <access_token>
Content-Type: application/json
{
"type": "message",
"from": {
"id": "<my bot id>",
"name": "Standup Alice"
},
"conversation": {
"id": "<conversation id>",
"name": "News Alert"
},
"recipient": {
"id": "<my user id>",
"name": "Bao"
},
"channelId": "skype",
"text": "My bot's reply"
}
Response (http error 400 - bad request):
{
"error": {
"code": "ServiceError",
"message": "The conversationId <conversation id>and bot <my bot id> doesn't match a known conversation"
}
}
Do you have an idea what's wrong with my requests and parameters?
Note 1: I tried to fire request to https://api.botframework.com/v3/conversations as described in https://docs.botframework.com/en-us/core-concepts/overview/#navtitle, but always receives http error 404 - Resource not found.
Note 2: I just tried the same way for webchat and it works fine, but MS Teams doesn't work (http error 500 - Internal Server Error)
Note 3: my channel settings
Your second API request (the one starting a conversation) should have returned something looking like this:
{
"activityId": "string",
"serviceUrl": "string",
"id": "string"
}
The fact that it didn't suggests to me that that's where the problem is (although full disclosure, I wasn't able to re-create it).
Looking at your "members" array, I see you added the bot. I'm not sure, strictly speaking, that a bot is a member (I think members are human, but I can't find a good definition). So, my best suggestion would be to remove the bot from the members array in that second API call.
Good luck!

Resources