"publishedAfter" parameter in Youtube Data API does not work as expected - youtube

I am making a call to the endpoint search in Youtube Data API using the following URL:
https://www.googleapis.com/youtube/v3/search?part=snippet&forMine=true&type=video&publishedAfter=2015-01-10T00:00:00Z&access_token=access_token
However, when I put the "publishedAfter" parameter, I get a confused answer:
{ "error": {
"errors": [
{
"domain": "youtube.search",
"reason": "invalidSearchFilter",
"message": "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters.",
"locationType": "parameter",
"location": ""
}
],
"code": 400,
"message": "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters." } }
I have already tested with the parameters of the error message and the call does not work. Does anyone have any idea why this occurs? I've tried different date formats in "publishedAfter", but none worked.

Related

Unsupported Media Type - 415 error in POST request in Graph Explorer

I am trying out Graph Explorer. I am able to get my profile from https://graph.microsoft.com/v1.0/me/.
But when I try to create a device using the Graph Explorer, it is returning Unsupported Media Type - 415 response.
My request and response are:
Request
POST https://graph.microsoft.com/v1.0/devices
Request headers
Content-type: application/json
Request body
{
"accountEnabled": false,
"alternativeSecurityIds": [
{
"type": 3,
"key": "base64Y3YxN2E1MWFlYw=="
}
],
"deviceId": "4c299165-6e8f-4b45-a5ba-c5d250a707ff",
"displayName": "Test device",
"operatingSystem": "linux",
"operatingSystemVersion": "1"
}
I have given the consent for all permissions under Modify permissions section.
Response
Unsupported Media Type - 415 - 1168ms
{
"error": {
"code": "Request_BadRequest",
"message": "The specified content type 'application/json;odata=minimalmetadata, application/json' contains either no media type or more than one media type, which is not allowed. You must specify exactly one media type as the content type.",
"innerError": {
"request-id": "11235ffc-1fb3-4324-a832-2c92274e98bf",
"date": "2020-04-06T16:55:17"
}
}
}
Edit
value of deviceId in the request data
"DeviceId" AND "Key" that you are passing in Request body should be Unique identifier. Change you sample Device-Id & Key and try again. It worked for me. and you also increased the length of device id by appending 1 at end.
Documentation for accountEnabled here.

YouTube Data API v3: How to filter ALL of a user's videos by date?

I am trying to get a list of an authenticated user's videos that were uploaded within a specific date range, regardless of status (private, unlisted, public, etc...) Looking at the API documentation, it appears that the only relevant endpoints that accept dates as query parameters are the /search and /activities endpoints.
However, when attempting to use the publishedAfter or publishedBefore parameters of these endpoints, the responses only include public videos. I've tried alternatively setting the mine and forMine parameters vs. channelId of the authenticated user's channel, but the result is the same. Additionally, attempting to use the /search endpoint with publishedAfter or publishedBefore and forMine==true returns a 400 error specifying an invalid combination of filters.
Is there any way to filter ALL of a user's videos by date via API? I've looked through similar questions, and the general response is to use order and maxResults to do the filtering in the response. I'd like to avoid this if at all possible due to the fact that the potential users of my application have fairly large numbers of videos (~10,000), which makes response filtering a highly inefficient method.
Example request to /search using forMine==true and dates:
https://www.googleapis.com/youtube/v3/search?access_token={token}&part=snippet&forMine=true&publishedAfter=2018-04-01T04:00:00.000Z&publishedBefore=2018-05-17T04:00:00.000Z&type=video
Response:
{
"error": {
"errors": [
{
"domain": "youtube.search",
"reason": "invalidSearchFilter",
"message": "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set either the <code>forContentOwner</code> or <code>forMine</code> parameters to <code>true</code>. You must also set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters.",
"locationType": "parameter",
"location": ""
}
],
"code": 400,
"message": "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set either the <code>forContentOwner</code> or <code>forMine</code> parameters to <code>true</code>. You must also set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters."
}
}
This same request without the publishedAfter and publishedBefore parameters returns all of the user's videos as expected.

Google Youtube API nextPageToken

I have read a lot of the other post about using the nextPageToken with the Youtube API.
The reference I am using is
https://developers.google.com/apis-explorer/?hl=en_US#p/youtube/v3/youtube.commentThreads.list?part=snippet&maxResults=100&order=time&videoId=xyvQaVUeu90&fields=items(id%252Csnippet%252FtopLevelComment%252Fsnippet%252FtextDisplay)%252CnextPageToken&_h=35&
The video id i am using is xyvQaVUeu90
The script I run returns a nextPageToken as
QURTSl9pMm1EbHlJZFdJTENzcHpIMGI3VWllOVl0enBxREN3NlZSYzAzZVdQTkNKNV9XQkpmQTNYLWhhVDIzeGN5eUdXUDZqWUJkdFdBOGdKVksyOENUU3B4b014Yi12Y05PdGRRcVlTaHp3VXEyR0JxRFVYMm5rWG1sbUZsRmk
So according to the API, if I use that nextPageToken it should return the next page of comments, however when I place the nextPageToken as the pageToken
Reference:
https://developers.google.com/apis-explorer/?hl=en_US#p/youtube/v3/youtube.commentThreads.list?part=snippet&maxResults=100&order=time&pageToken=QURTSl9pMm1EbHlJZFdJTENzcHpIMGI3VWllOVl0enBxREN3NlZSYzAzZVdQTkNKNV9XQkpmQTNYLWhhVDIzeGN5eUdXUDZqWUJkdFdBOGdKVksyOENUU3B4b014Yi12Y05PdGRRcVlTaHp3VXEyR0JxRFVYMm5rWG1sbUZsRmk&videoId=xyvQaVUeu90&fields=items(id%252Csnippet%252FtopLevelComment%252Fsnippet%252FtextDisplay)%252CnextPageToken&_h=36&
It returns:
{
"error": {
"errors": [
{
"domain": "youtube.parameter",
"reason": "invalidPageToken",
"message": "The request specifies an invalid page token.",
"locationType": "parameter",
"location": "pageToken"
}
],
"code": 400,
"message": "The request specifies an invalid page token."
}
}
Any help would be nice!
It's working perfectly. Just make sure to copy everything between the double quotes ("") . I was able to use it without problems. For example the nextPageToken provided in your link is
"QURTSl9pMFZuQUJYNGc4dDVZRjRjYlJ3d0M1MlIzeTRSeEJfclZOeEEzdncxRVM4bGZFOXdIRVVVRkJibjBSVW5xaEtBTE1zS0VTd2lDNndrRmJQaG4tY1dScXFral9hMVQ3NmJidFI1Vk83a0xhWEJNU2cwMlYweERGLU1uMDhLazg="
but you only copied
QURTSl9pMFZuQUJYNGc4dDVZRjRjYlJ3d0M1MlIzeTRSeEJfclZOeEEzdncxRVM4bGZFOXdIRVVVRkJibjBSVW5xaEtBTE1zS0VTd2lDNndrRmJQaG4tY1dScXFral9hMVQ3NmJidFI1Vk83a0xhWEJNU2cwMlYweERGLU1uMDhLazg
You did not include =

Youtube api search with location retrieve error

I have the following request:
https://www.googleapis.com/youtube/v3/search?part=snippet&location=+37.42307%2C-122.08427&locationRadius=1500mi&q=israel&access_token=ya29.CjHzAvvmL97PFzMkIopmF9nT4IVdznARs30XrE5i1_i6j3eQxBlbNdktch2iIHqz1-x7
And I receive the following error:
{
error: {
errors: [
{
domain: "youtube.search",
reason: "invalidSearchFilter",
message: "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters.",
locationType: "parameter",
location: ""
}
],
code: 400,
message: "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters."
}
}
As the error message say you have to define the type parameter to video.
So your call must be something like this:
https://www.googleapis.com/youtube/v3/search?part=snippet&location=37.42307,22.08427&locationRadius=50km&q=israel&access_token=ya29.CjHzAvvmL97PFzMkIopmF9nT4IVdznARs30XrE5i1_i6j3eQxBlbNdktch2iIHqz1-x7&type=video
Also, the API does not support locationRadius parameter values larger than 1000 kilometers, so you have to define a smaller than 1500mi.(Reference)
You can test all the parameters here
Last but not least don't upload public your access_token. It is supposed to be secret. You have to change it now since you made it public, or someone can use it for his own needs

What is the proper way to list all youtube broadcasts on behalf of the Content Owner (Youtube Partner) using Youtube API V3?

I tried this:
Went here - https://developers.google.com/youtube/v3/docs/search/list
Set the following parameters:
part - snippet
eventType - live (Also tried, completed)
forContentOwner - true
onBehalfOfContentOwner - 'Partner ID'
type - video
I have properly authenticated using the partners login credentials by switching on the OAuth at the top right of the form.
The documentation says, if 'eventType' is set, then the 'type' should be set to 'video' and if 'forContentOwner' is set then onBehlafOfContentOwner should be supplied and should be properly authenticated all of which I clearly did but I get the following error:
400 Bad Request
- Show headers -
{
"error": {
"errors": [
{
"domain": "youtube.search",
"reason": "invalidSearchFilter",
"message": "Invalid combination of search filters and/or restrictions.",
"locationType": "parameter",
"location": ""
}
],
"code": 400,
"message": "Invalid combination of search filters and/or restrictions."
}
}
As it says in the debug info: video_filter is unsupported in combination with for_content_owner filter.
So you can not do it this way.

Resources