Google's ampUrls:batchGet returns 404? - google-api

We've built back in 2017 or so a scheduled script that tests bunch of URIs against Google's AMP validation API.
Haven't checked the script in ages, but recently one of our users complained that none of the URIs list AMP equivalents (the reason we used the API for, to look up AMP versions of the pages).
Now, looking at Google's documentation and testing our JSON payload with the embedded test panel there, everything works.
But when doing the same data from our servers against the API endpoint they list, we get 404 error. Actually, just copy/pasteing the API endpoint URI to a browser returns 404, too, which is kinda unexpected.
Is there something we're missing or has Google simply shut down the service, without notifying on their documentation page about it, or..?
I am simply posting basic JSON payload with URIs that I want to check if they have AMP version available, as, for example, this:
{
"urls": [
"https://www.dailymail.co.uk/sport/football/article-6729017/Is-VAR-working-change-Reporters-analyse-video-technology-football.html?ns_mchannel=rss&ns_campaign=1490&ito=1490",
"https://www.talouselama.fi/uutiset/te/2223797c-6be5-3be1-b1aa-f774ff23d63e","https://www.theguardian.com/uk-news/2019/feb/21/teenager-shot-in-fight-on-london-tube-barking-hammersmith-and-city-line"
],
"lookupStrategy": "FETCH_LIVE_DOC"
}
to:
https://acceleratedmobilepageurl.googleapis.com/v1/ampUrls:batchGet
with POST, having service key as the query parameter (?key=xxx).
Whats we get in return, is 404. No errors, no JSON data, just plain old HTML formatted 404.

The service is fine and your query should return:
{
"ampUrls": [
{
"originalUrl": "https://www.theguardian.com/uk-news/2019/feb/21/teenager-shot-in-fight-on-london-tube-barking-hammersmith-and-city-line",
"ampUrl": "https://amp.theguardian.com/uk-news/2019/feb/21/teenager-shot-in-fight-on-london-tube-barking-hammersmith-and-city-line",
"cdnAmpUrl": "https://amp-theguardian-com.cdn.ampproject.org/c/s/amp.theguardian.com/uk-news/2019/feb/21/teenager-shot-in-fight-on-london-tube-barking-hammersmith-and-city-line"
},
{
"originalUrl": "https://www.dailymail.co.uk/sport/football/article-6729017/Is-VAR-working-change-Reporters-analyse-video-technology-football.html?ns_mchannel=rss&ns_campaign=1490&ito=1490",
"ampUrl": "https://www.dailymail.co.uk/sport/football/article-6729017/amp/Is-VAR-working-change-Reporters-analyse-video-technology-football.html",
"cdnAmpUrl": "https://www-dailymail-co-uk.cdn.ampproject.org/c/s/www.dailymail.co.uk/sport/football/article-6729017/amp/Is-VAR-working-change-Reporters-analyse-video-technology-football.html"
}
],
"urlErrors": [
{
"errorCode": "NO_AMP_URL",
"errorMessage": "No AMP URL for the request URL.",
"originalUrl": "https://www.talouselama.fi/uutiset/te/2223797c-6be5-3be1-b1aa-f774ff23d63e"
}
]
}

Related

How to exclude domains in the Houndify API?

How can i exclude Domains in the Houndify API?
In the RequestInfoJSON documentation is a field called domains to "omit some domains when doing a request". However there is no format specified.
By analysing the SDK i discover the following structure:
"Domains": {
"Exclude": {
"DomainNames": ["weather"]
}
}
However, no matter which domain name i put into the array the domain will be executed. (By using the "only" functionality i got a NoResultCommand.) Disabling the domains in the dashboard is no option for me.
Here is the doc explaining "Domains" parameter.
Specifying following value to "Domains" parameter as part of request header in API tester seems to have successfully suppressed "Wikipedia" domain to be invoked:
{"Exclude": {"DomainNames": ["Wikipedia"]}}

AWS Lambda function works fine when invoked manually, but not through endpoint

I have a Lambda function, attached to an API Gateway endpoint, that lists the items under an ID in DynamoDB.
I've built my function using the Serverless Framework. When I invoke the function locally (serverless invoke local ...) it works fine. When I test it manually on the AWS Lambda console, it works fine, but when I call it from the API Gateway, it doesn't work.
It's configured to use this payload: (What I've used for testing)
{
"requestContext": {
"identity": {
"cognitoIdentityId": "468648c5-b135-4075-910a-8a648d66e67d"
}
}
}
In my app, I use the aws-amplify package. This is how I call the endpoint:
data = await API.get('endpoint-name', '/endpoint', {
body: {
requestContext: {
cognitoIdentityId: '468648c5-b135-4075-910a-8a648d66e67d'
}
}
});
Here, I get a 403 error. If I call it without the extra data, i.e:
data = await API.get('endpoint-name', '/endpoint');
I get an empty list [ ], but no error. Does aws-amplify automatically populate the cognitoIdentityId field? I'm following the serverless-stack tutorial, and they kinda gloss over this.
I also have CloudWatch set up, and I cannot see anything funky there. Any ideas on how to fix / debug this issue?
Cheers!
Ah - I think I solved it!
I configured my endpoint to take parameters from the body of a GET request, however (I think) either aws-amplify or the API Gateway doesn't support a request body when performing a GET. I noticed this by manually testing the API Gateway (Which I hadn't done before), and it stated Request Body is not supported for GET methods.
So I think I'll have to pass my parameters in the URL itself.

How to send custom form data to FineUploader Azure Success endpoint?

I am using FineUploader 5.13.0 with the Azure Blob Storage end point.
I have it successfully uploading files directly to blob storage, and also successfully hitting my web server success endpoint when the upload is concluded.
However, I am looking for a way to include custom data in the post to the success endpoint.
This bit in the documentation seems to imply that it is possible.
Under the section "Optional server-side tasks" for "uploadSuccess.endpoint", it says it will send
"Any parameters/form fields you have associated with the file".
However, I just cannot seem to figure out how to do that.
This issue seems to refer to it, but doesn't give enough info.
https://github.com/FineUploader/fine-uploader/issues/1313
Note, I am not referring to the feature to hook into existing HTML forms as explained on this documentation page:
"Integrating with Existing HTML Forms"
https://docs.fineuploader.com/branch/master/features/forms.html
You might be looking for FineUploader's Request params. This allows you to add extra form data.
Eg:
new qq.FineUploader({
// elided
request: {
params: {
testing: "THIS IS A TEST"
}
}
});
This will show up in the multi-part body of the request:

Trying to stop Google Directory API push notifications with a client returns 404

Using the documentation at https://developers.google.com/admin-sdk/directory/v1/guides/push#creating-notification-channels I subscribed to a notification using something like:
service = build('admin', 'directory_v1', credentials=credentials)
watch_data = {
'id': str(uuid.uuid1()),
'type': 'web_hook',
'address': 'https://example.appspot.com/push/user',
'payload': True,
}
subscription = service.users().watch(domain=domain, event='update', body=watch_data).execute()
# 'subscription' is stored
I got a proper reply and everything seem fine to that point.
Until I try to stop the notification with the following code:
# 'subscription' is retrieved from the storage
service = build('admin', 'directory_v1', credentials=credentials)
stop_data = {
'id': subscription.id,
'resourceId': subscription.resource_id
}
request = service.channels().stop(body=stop_data)
request.execute()
This raises an 'HttpError' 404 exception:
Response: <HttpError 404 when requesting https://www.googleapis.com/admin/directory/v1/admin/directory_v1/channels/stop? returned "Not Found">
Interestingly, using the same parameters (known good 'id' and 'resourceId' from the same user), the API explorer gadget at https://developers.google.com/admin-sdk/directory/v1/reference/channels/stop fails in the same way.
I've also been unable to find this endpoint in the full blown API explorer.
I believe that the discovery somewhat misbehaves.
The URI built by the client is: 'https://www.googleapis.com/admin/directory/v1/admin/directory_v1/channels/stop'
whereas the documentation states it should be:
'https://www.googleapis.com/admin/directory/v1/channels/stop'.
Could this be a bug in the API?
I'll try to make a "manual" authenticated request ASAP to check this hypothesis.
Edit 2016-11-09:
Tried a manual request using the following code:
# 'subscription' is retrieved from the storage
stop_data = {
'id': subscription.id,
'resourceId': subscription.resource_id
}
http = httplib2.Http()
http = credentials.authorize(http)
url = 'https://www.googleapis.com/admin/directory/v1/channels/stop'
method = 'POST'
response, content = http.request(url, method, body=json.dumps(stop_data),
headers={'content-type': 'application/json'})
I still get a 404 as a result. So I guess that the problem is not the endpoint URI.
If someone from Google reads this, can you please look into it?
It's not super critical but I'd like to not have dangling notification subscriptions.
Edit 2 2016-11-09:
Thanks to #Mr.Rebot for pointing out the reports API bug report.
Upon closer inspection, the problem here is exactly the same.
Using the manual request code above but adjusting the URI with an underscore, I'm finally able to make a successful request (returns 204).
url = 'https://www.googleapis.com/admin/directory_v1/channels/stop'
So there's definitely a bug somewhere and the following documentation pages have the wrong endpoint URI:
https://developers.google.com/admin-sdk/directory/v1/guides/push#stopping-notifications
https://developers.google.com/admin-sdk/directory/v1/reference/channels/stop
Also found this related post: Google Admin SDK Channel Stop endpoint is broken in client libraries
To those that wonders in the Google Docs hell for the past two years, and counting.
The wrong/right URL is:
https://www.googleapis.com/admin/reports_v1/channels/stop
And the Scope to use this URL is:
https://www.googleapis.com/auth/admin.reports.audit.readonly
I hope this helps someone :)

getting jsonp to work in asp.net api

having issues getting my jsonp to work with my client backbone script,pagenator keep gettgin invalid key error
having looked around people say its to to do with my service not return jsonp.
For example SyntaxError: invalid label, i've written a mvc4 web api service this is what it returns does it look right and also is there anything i need to add to my api to support jsonp ?
{
"odata.metadata":"http://test.test.uk/api/odata/$metadata#lnews","value":[
{
"ID":1,"title":"This is a test news artical","mainContent":"<p>\r\n\tthis is a test article</p>\r\n","featured":1,"visiblehomepage":1,"thedatetime":"2013-08-05T10:36:05.98","expireon":"2013-08-15T00:00:00","category":17,"embargo":null,"embargotime":"PT0S","embargodate":null,"customthumbnail":null,"news_layout":3,"LNBE":0,"LNBN":0,"LNBS":0,"LNBW":0,"LNWV":0,"LNWS":1,"LNDY":0,"LNSW":0,"LNSH":0,"LNCV":0
},{
"ID":2,"title":"This is a test article","mainContent":"<p>\r\n\twelcome to the best site in the world</p>\r\n","featured":1,"homepage":1,"thedatetime":"2013-08-05T10:42:54.763","expireon":"2013-08-22T00:00:00","category":null,"embargo":null,"embargotime":"PT0S","embargodate":null,"customthumbnail":"Water lilies.jpg","news_layout":4,"LNBE":1,"LNBN":1,"LNBS":1,"ff":1,"LNWV":1,"LNWS":1,"LNDY":1,"LNSW":1,"LNSH":1,"LNCV":1
}
]
}
Here is a JSONP URL:
http://odata.netflix.com/v2/Catalog/Genres?$format=json&$callback=?
Here is a diagram:
CLIENT SERVER
------ ------
Makes URL request Looks up function matching this URL param ($callback)
Executes asynchonously If found, executes function asynchonously
Returns from callback Returns data from server side as a function, or error
References
Learn By Example Guide for Select State.gov Data (SSD): JSONP

Resources