Do batch requests for the YouTube Data API work? - youtube-api

I send a request to https://www.googleapis.com/batch/youtube/v3, but I get a 404 anyway. Perhaps I am sending the request incorrectly, but most likely the endpoint is not working.
As well as, I use Postman to test with next creds:
1. POST request to https://www.googleapis.com/batch/youtube/v3.
2. Set "Content-type" header to multipart/mixed.
3. Add raw text body with as HTTP:
GET https://www.googleapis.com/youtube/v3/channels?part=snippet&id=2222222&key=* HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=UTF-8
GET https://www.googleapis.com/youtube/v3/channels?part=snippet&id=1111111&key=* HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=UTF-8
Any suggestions for NodeJS?

YouTube Data API version 3 does support batch processing only of the following form:
Batch processing – The v3 API supports one of the batch processing use cases that the v2 API had supported. The v3 API's channels.list, channelSections.list, guideCategories.list, playlistItems.list, playlists.list, subscriptions.list, videoCategories.list, and videos.list methods all support an id parameter, which can be used to specify a comma-delimited list of IDs (video IDs, channel IDs, etc.). Using those methods, you can retrieve a list of multiple resources with a single request.
According to the docs, in case of Channels.list API endpoint, you're able to batch several calls, since, the id property accepts multiple channel IDs in one go:
id (string)
The id parameter specifies a comma-separated list of the YouTube channel ID(s) for the resource(s) that are being retrieved. In a channel resource, the id property specifies the channel's YouTube channel ID.
Note that the API provided me with the following response when asking the Videos.list endpoint to produce info for 64 videos in one go (even only 51 produced the same response):
ERROR 400: Bad Request
{
"error": {
"code": 400,
"message": "The request specifies an invalid filter parameter.",
"errors": [
{
"message": "The request specifies an invalid filter parameter.",
"domain": "youtube.parameter",
"reason": "invalidFilters",
"location": "parameters.",
"locationType": "other"
}
]
}
}
Therefore this API endpoint does not accept more than 50 IDs. It's very much presumable that the others will function the same way.

Related

Why am I getting a page token error while using the live chat API?

I'm trying to get the live chat of the live stream:
https://www.youtube.com/watch?v=xHtuITYCqcM.
So for that, I made the URL:
https://youtube.googleapis.com/youtube/v3/liveChat/messages?liveChatId=xHtuITYCqcM&key=...,
and it returns the following:
{
"error": {
"code": 400,
"message": "page token is not valid.",
"errors": [
{
"message": "page token is not valid.",
"domain": "youtube.liveChat",
"reason": "pageTokenInvalid"
}
]
}
}
If anyone knows why is this happening, please help me.
I'm new to this platform, so if I missed anything, please tell me.
According to the official specification of the LiveChatMessages.list API endpoint, its request parameter liveChatId is defined as follows:
liveChatId (string)
The liveChatId parameter specifies the ID of the chat whose messages will be returned. The live chat ID associated with a broadcast is returned in the liveBroadcast resource's snippet.liveChatId property.
Consequently, passing to this endpoint the respective stream's video ID -- xHtuITYCqcM -- is incorrect.
You'll have to invoke, as specified above, the LiveBroadcasts.list API endpoint, passing to it the request parameter id set to your stream's video ID -- that is xHtuITYCqcM -- by means of an URL like this one:
https://www.googleapis.com/youtube/v3/liveBroadcasts?id=xHtuITYCqcM&part=snippet&fields=items.snippet.liveChatId&access_token=$ACCESS_TOKEN
where $ACCESS_TOKEN is the access token obtained upon running to successful completion an OAuth 2.0 authentication/authorization flow.
Note that the OAuth flow is actually required (an API key does not suffice), because:
Authorization
This request requires authorization with at least one of the following scopes (read more about authentication and authorization).
Scope
https://www.googleapis.com/auth/youtube.readonly
https://www.googleapis.com/auth/youtube
https://www.googleapis.com/auth/youtube.force-ssl
Also note that above I used the fields request parameter for to get from the API only the info that's of actual use (a good practice).

Postman - Unable to send Post Twilio API request

URL: https://api.twilio.com/2010-04-01/Accounts/{{Twilio_ACCOUNT_SID}}/Messages.json
I am trying to send a Post request using Twilio "send SMS API" in Postman. When I run the request I encounter:
{
"code": 21604,
"message": "A 'To' phone number is required.",
"more_info": "https://www.twilio.com/docs/errors/21604",
"status": 400
}
I am using a free trial account. The "To" Number works fine in Twilio and is validated. I have x-www-form-urlencoded selected in the body of the Post Request in Postman.
It complains about To missing not it being not validated, check your request configuration in Postman.
The Authorisation section should look like this:
And the Body section like this:
Make sure that you call your key To (that is uppercase T and lowercase o) and that you provide a E.164 formatted number.

When listing children of folder I get error 501 The request is not supported by the system

If I want to list files in the folder with query parameter $orderBy according to the documentation, I get a response with error 501.
Here is a raw example of request:
GET /v1.0/drives/{id}/items/{id}/children?$select=name,id,folder,lastModifiedDateTime,createdDateTime,size,createdBy,lastModifiedBy,webUrl&$orderby=createdDateTime HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer <token>
The response is:
{
"error": {
"code": "notSupported",
"message": "The request is not supported by the system.",
"innerError": {
"request-id": "c925ae56-8359-4e8f-98b9-92ff0c4dfc8a",
"date": "2018-06-04T10:50:00"
}
}
}
This problem I have only with a specific OneDrive account. If I use the same API call for a different drive and folder, then it works well without any problem.
When I investigated it then it seemed like the API doesn't support parameter $orderBy with date variable inside for this account at all.
Does anyone know why I get this error for a specific account?

Twilio Outbound POST: Content-Type on Text

My goal is to take a text message sent to Twilio #, POST that information to my platform (ServiceNow). I believe my issue is that ServiceNow Script API can only receive content-type = [application/json, application/xml, text/xml] and so I get an error response invalid content type.
Looking at Twilio debugger, I don't see any explicit parameter called content-type. Any insights on what I might do here?
Response:
{
"error": {
"message": "Invalid content-type. Supported request media types for this service are: [application/json, application/xml, text/xml]",
"detail": null
},
"status": "failure"
}
Twilio developer evangelist here.
When Twilio sends a webhook for an incoming message the request is formatted as application/x-www-form-urlencoded.
If you are unable to find a way for ServiceNow to accept application/x-www-form-urlencoded you could try using a Twilio Function to translate the data to JSON and send it on to your endpoint.
Let me know if that helps at all.

How do I insert multiple rows in POST body? Google Fusion Tables API V1.0

I could insert rows by QueryString sql parameter. https://developers.google.com/fusiontables/docs/v1/reference/query/sql?hl=ja
But the reference document describes that you can use sql parameter as body of POST for inserting rows. I can't. How do I do? https://developers.google.com/fusiontables/docs/v1/using?hl=ja#insertRow
First reference describes that QueryString sql parameter required. I got error 400 by omitting sql in QueryString. Using QueryString has limitation(URL length). I want to insert many rows in body of POST.
request:
POST https://www.googleapis.com/fusiontables/v1/query?access_token={my access token} HTTP/1.1
Content-Type: application/json
sql=INSERT INTO 1JOgUG5QWE5hybrDAd2GX3yfjVCGoM6u7WkSVDok ('_id', '_count', 'start_time', 'end_time', 'counts', 'start_plaece', 'end_place', 'distance', 'average_speed', 'send_flag', 'time_span', 'train_type', 'calories', 'weight', 'status', 'map_url', 'rally_id' ) VALUES ('-1', '0', '2013/01/19 09:00:00.000', '2013/01/19 12:34:56.000', '9876', 'Tokorozawa3', 'iidabashi2', '45678', '67', '0', '986532', '1', '389', '77.70', '0', 'http://www.google.com/', '3');
response:
body {
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter: sql",
"locationType": "parameter",
"location": "sql"
}
],
"code": 400,
"message": "Required parameter: sql"
}
}
The documentation is faulty and there are some deatils missing.
You can use the sql=... parameter in the request url. The ContentType header usually is application/json but the API probably accepts other too. In this case you're limited in 2048 characters URL length.
You van also use sql=... in the POST body. In this case you have to set the ContentType must be application/x-www-form-urlencoded. You are limited to 500 INSERT statements in 1 request.
Another option is to use the importRows method. Here you will use a CSV as the POST body. In this method you're limited by 100MB uploaded data. The ContentType must be "application/octet-stream".
More details here: importRows reference

Resources