Google image search api. Bad request - json

I'm using Google CustomSearch API v1 for image search but I have a problem with my JSON request.
When I filled out the search.cse.list (here) I got the JSON request like this:
GET https://www.googleapis.com/customsearch/v1?q=test&cref=AIzaSyAreDhTh3IqaGPqC44t08sQF_qbSGzzA7Q&cx=010855067127206535986%3Aqdh_vhglb4u&fileType=jpg&filter=1&imgSize=medium&imgType=news&num=4&searchType=image&start=1&key={YOUR_API_KEY}
And the response of this request:
{
"kind": "customsearch#search",
"url": {
"type": "application/json",
"template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json"
},
"queries": {
...
},
"context": {
...
},
"searchInformation": {
...
},
"items": [
{
"kind": "customsearch#result",
"title": "free student testing cartoons | Home > Clipart > Cartoons ...",
"htmlTitle": "free student <b>testing</b> cartoons | Home > Clipart > Cartoons <b>...</b>",
"link": "https://s-media-cache-ak0.pinimg.com/236x/30/0c/a5/300ca57d460ab787202e36bdf0364e57.jpg",
"displayLink": "www.pinterest.com",
"snippet": "free student testing cartoons",
"htmlSnippet": "free student <b>testing</b> cartoons",
"mime": "image/jpeg",
"image": {
"contextLink": "https://www.pinterest.com/pin/568157309212095926/",
"height": 213,
"width": 236,
"byteSize": 14426,
"thumbnailLink": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQ-JefdKWd1WZkuesaq01zldYRW2JmYd_z0cW0SF9OEXFMVr6M8XZO4kg",
"thumbnailHeight": 98,
"thumbnailWidth": 109
}
},
But when I tried to use this request at the browser bar I got an error:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "ipRefererBlocked",
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
"extendedHelp": "https://console.developers.google.com"
}
],
"code": 403,
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
}
}
I guess that I should use Ajax call, but I dont know how can I do it, because I am beginner.
I also made an API Key, "cx" and have enabled CustomSearch API at my console.developer account.
So the question is: How can I get values from this JSON request and then operate with them if I even cant get values in my browser? I want to get an image-link from this request.
Sorry for my English.

The Google Image Search API was deprecated in 2011, and has finally, now, been switched off :( You'll have to find something else to use, sorry :(

Related

Getting 400 error ( invalid argument - latlng )while updating the location details via Google my business API

I've a business published in Google My business.It is in live. I tried to update the location details via API. But I'm getting 400 error and getting the following response.
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.mybusiness.v4.ValidationError",
"errorDetails": [
{
"code": 3,
"field": "latlng",
"message": "The specified address cannot be located. Please use the UI to provide a pin drop."
}
]
}
]
}
}
But in the above scenario, patch request doesn't contains the location coordinates. But I still getting the specified address cannot be located response.
Body of patch request::
{
"primaryPhone": "xxxxxxxxx",
"locationName": "xxxx",
"address": {
"regionCode": "IN",
"postalCode": "xxxxx",
"locality": "xxxxx",
"addressLines": [
"xxxxxx xxxx xxxx"
],
"administrativeArea": "xxxx xxxxxx"
},
"primaryCategory": {
"displayName": "Apartment building",
"categoryId": "gcid:apartment_building"
},
"languageCode": "en",
"storeCode": "xxxxxx9dda0dc5-c709-410c-a272-912486b1b5f4"
}
This is doesn't contains the lat,lng but still getting the same lat,lng field error.
Actually I've changed the name only change . I don't know how it is related to lat,lng.
And tried updating without the address field and with address field. But in both case getting the same response.
Seems like you are using this method (https://developers.google.com/my-business/reference/rest/v4/accounts.locations/patch).
This error occurs when Google determines that their own Geocoder doesn't really know where they should be placing the pin for that address. So additionally to the address property, Google may(!) allow you to also send them the latLng property - if Google determines that this is a credible set of coordinates, the address will be updated.
It is however still possible that they won't believe you that you know where that address is exactly. In that case, the only way to get address data through is in fact to go to the Google My Business UI of the location and manually dragging that pin to where it needs to go.

google drive API verified domain not working with changes watch

According to https://developers.google.com/drive/api/v3/reference/changes/watch,
you need an https address to make it works if you need to watch over a change of resources.
I've configured the domain successfully by going to Google Cloud Console > Domain Verification > Add Domain.
Then I use Postman to make a call to test it:
https://www.googleapis.com/drive/v3/changes/watch?pageToken=nextPageToken
{
// "kind": "api#channel",
"id": "1234231",
"expiration": 1656402233000,
"type": "webhook",
"payload": true,
"address": "https://mrnoc.blogspot.com",
"params": {
"pageToken": "nextPageToken"
}
}
However, it failed and generated this error message:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "push.webhookUrlUnauthorized",
"message": "Unauthorized WebHook callback channel: https://mrnoc.blogspot.com"
}
],
"code": 401,
"message": "Unauthorized WebHook callback channel: https://mrnoc.blogspot.com"
}
}
I have no idea how it doesn't work, I've tried to look around but it a dead end as it seems like I've configured everything properly.
Please help if you know what might stop it from working.
Thank you

Google My Business API - Use the UI to provide a pin drop

I am trying to update a listing on Google My Business with a new description, in doing this you have to update the whole listing. When trying to update the address I get the response;
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com\/google.mybusiness.v4.ValidationError",
"errorDetails": [
{
"code": 1100,
"field": "address",
"message": "The specified address cannot be located. Please use the UI to provide a pin drop."
}
]
}
]
}
The address is exactly the same as what has been retrieved from Google just 20 minutes earlier so there is no difference to what shows in Google. Is there any way to update this listing?
Google detail that you should use a UI to position the Map Pin to update the listing if this is done what is the new information provided back to Google?

OneNote API Get Notebooks issue

The following is a sample schema from the OneNote API documentation at this site and will can be used with json2csharp.com with no problems.
http://dev.onenote.com/docs#/reference/get-notebooks.
{
"createdBy": "user name",
"createdTime": "2013-10-05T10:57:00.683Z",
"id": "notebook ID",
"isDefault": false,
"isShared": false,
"lastModifiedBy": "user name",
"lastModifiedTime": "2014-01-28T18:49:00.47Z",
"links": {
"oneNoteClientUrl": {
"href": "onenote:https://{client URL}"
},
"oneNoteWebUrl": {
"href": "https://{web URL}"
}
},
"name": "notebook name",
"sectionGroupsUrl": "https://www.onenote.com/api/v1.0/notebooks/{notebook ID}/sectionGroups",
"sectionsUrl": "https://www.onenote.com/api/v1.0/notebooks/{notebook ID}/sections",
"self": "https://www.onenote.com/api/v1.0/notebooks/{notebook ID}",
"userRole": "Contributor"
}
However, using the following Get Notebooks link has a different schema that doe
sn't pass json2csharp. Parsing your JSON didn't work. Please make sure it's valid.
"https://graph.microsoft.com/v1.0/me/onenote/notebooks"
createdBy and lastmodifiedBy are thrown as exceptions.
The sample from the apigee.com/console app uses the https://www.onenote.com/api/v1.0/me/notes/notebooks link and has the correct schema.
How do I resolve this discrepancy? Or am I mistaken?
The response payload returned from the Microsoft Graph API is slightly different from the response payload returned from the OneNote API directly.
Here's a reference to the notebook properties returned from Microsoft Graph: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/notebook
And this is what gets returned from the OneNote API directly:
https://msdn.microsoft.com/en-us/library/office/dn769050.aspx => Response properties

Graph API: Check if feed post was made by a Page or User

When using the /page/feed endpoint in the Facebook Graph API I can't figure out how to know if the post was made by a Page or a User
Here's how I call the endpoint right now:
HTTP GET https://graph.facebook.com/v2.8/{page_id}/feed?fields=is_published,from,message
This yields the following JSON response:
{
"data": [
{
"from": {
"name": "Chad Smith", # <-- This is a User
"id": "806273209398023"
},
"message": "A really magical place! Best Christmas...",
"id": "103988597020_1445496708809010"
},
{
"from": {
"name": "Tivoli", # <-- This is a Page
"id": "103988597020"
},
"message": "Hello everybody...",
"id": "103988597020_10154040865527021"
},
]
}
How can I know if the post was from a Page or User without making additional API calls? I've tried using subfields, but can't figure out if they work on the from field.
I solved it by using ?fields=from{name,about} and marking it as a Page if the from JSON contains about.
This is not the best solution, but about is currently the only subfield of from that doesn't fail on User. (e.g. if I was using ?fields=from{fan_count} the Graph API will fail for posts made by User objects.