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
Related
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.
I'm just trying to make a search over youtube for my own videos that publisher after X date
However when i use publishAfter parameter, it's giving invalidSearchFilter error even of i set type parameter as video.
Error description is like this:
The request contains an invalid combination of search filters and/or restrictions. Note that you must set the type parameter to video if you set either the forContentOwner or forMine parameters to true. You must also set the type parameter to video if you set a value for the eventType, videoCaption, videoCategoryId, videoDefinition, videoDimension, videoDuration, videoEmbeddable, videoLicense, videoSyndicated, or videoType parameters.
You can reproduce this error from: https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet&forMine=true&publishedAfter=1970-01-01T00%253A00%253A00Z&type=video&_h=11& (after login via oauth 2.0)
Any idea what can i do in this situation?
I used the link that you provided. The problem is not the date. The problem is the conflicting search restrictions that you used. To make your search work, leave the "forMine" parameter empty so it doesn't conflict with your date filters and possibly the 'q' parameter as well. Do that and it will work.
Also, you have to specify the channelID to specify it's yours. Give it a try
I am trying to work on a task to retrieve all the videos from our own channel, my problem with using forMine filter was, I was passing channelId filter alongside forMine filter (which actually does not make sense, if I am saying to get my own data then I should not pass channel id explicitly, so I blame myself for that), which was returning as an error saying that Request contains an invalid argument.
Here is what my request was when it was causing the error:
curl --location -g --request GET 'https://youtube.googleapis.com/youtube/v3/search?part=snippet,id&channelId=[Channel ID]&forMine=true&order=date&type=video&key=[API KEY]&maxResults=25' \
--header 'Authorization: Bearer [ACCESS TOKEN]' \
--header 'Accept: application/json'
And this was the JSON return:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"errors": [
{
"message": "Request contains an invalid argument.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
As soon as I removed the channelId query parameter, the error went away.
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.
What is the query to get emails received from a specific sender email address?
I have tried filtering on the "Address" property of the "From" property, which is a "Recipient" complex type according to O365 Microsoft.Exchange.Services.OData.Model namespace.
OData filtering on complex types goes something like this
/Me/Inbox/Messages?$filter=From/Address eq 'email#email.com'
However, this returns the following error:
"error": {
"code": "ErrorInvalidProperty",
"message": "The property 'Address' is invalid.",
"innererror": {
"message": "The property 'Address' is invalid.",
"type": "Microsoft.Exchange.Services.OData.InvalidPropertyException",
"stacktrace": " at Microsoft.Exchange.Services.OData.SchemaExtensions.ResolveProperty(Schema schema, String propertyName)\r\n at Microsoft.Exchange.Services.OData.Model.EwsFilterConverter.GetPropertyProvider(QueryNode queryNode)\r\n at Microsoft.Exchange.Services.OData.Model.EwsFilterConverter.ConvertFilterNode(QueryNode queryNode)\r\n at Microsoft.Exchange.Services.OData.Model.EwsQueryAdapter.GetRestriction()\r\n at Microsoft.Exchange.Services.OData.Model.MessageProvider.Find(String parentFolderId, MessageQueryAdapter queryAdapter)\r\n at Microsoft.Exchange.Services.OData.Model.FindMessagesCommand.InternalExecute()\r\n at Microsoft.Exchange.Services.OData.ODataCommand`2.Execute()\r\n at Microsoft.Exchange.Services.OData.ODataTask.Execute(TimeSpan queueAndDelayTime, TimeSpan totalTime)"
}
}
I got the same error that property of complex type is invalid.
It seems that exchange service does not support complex type filtering.
You can try getting all the Messages to local storage and doing filtering.
Email address is a complex type however it is listed as filterable (https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#RESTAPIResourcesMessage) which means the following should work...
https://outlook.office365.com/api/v1.0/me/messages?$filter=From/EmailAddress/Address eq 'email#email.com'
However, I'm having trouble with this, it seems to be simply returning blank values whereas the following works...
https://outlook.office365.com/api/v1.0/me/messages?$filter=From/EmailAddress/Name eq 'Joe Bloggs'
So, there could be a fault with the API or the email address might need to be formatted differently.
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