Inconsistent functionality on CommentThreads: insert on Youtube DATA API - google-api

i could need some help with the Youtube data API , i have a server in which utilizes the Youtube API in adding a youtube comment using JS , it's quiet simple :
const snippet = {
snippet: {
videoId:videoId,
topLevelComment:{
snippet:{
textOriginal:message
}
}
}
};
axios({
method: 'POST',
url: 'https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&alt=json&access_token='+access_token,
data : snippet
})
This used to work without any issues , but since yesterday, it stopped working , giving me this error :
"code": 400,
"message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the request's input is invalid. Check the structure of the <code>commentThread</code> resource in the request body to ensure that it is valid."
Now the bizarre thing is that , testing in a sandbox online with an axios client , this works , i tried with postman , it works , in the youtube code sample sandbox , it works and i'm able to add the comment using an access token , but in my server , it fails even though all of the data is passing correctly , it fails , even tho it is the exacty same request , giving me that error..
My server is hosted on heroku.
The quota limit is not reached , it is far from reached sine the api is only used once in a while.
I tried passing my API Key , but it's the same with or without it in all the above cases.
I don't know what to do from this point i'm utterly confused.
Any help would be appreciated , thank you.

Related

facing error in paystack integrattion in laravel 8

Hi I'm trying to integrate paystack in laravel 8 but I'm click paynow button it give following error
Client error: POST https://api.paystack.co/transaction/initialize resulted in a 404 Not Found response:
{
"status": false,
"message": "Invalid Split code."
}
anyone can help how can i solve this
thanks
Can you share the request body? It looks like you're trying to pass a split code when you're initializing the transaction, but the code you're passing either:
Doesn't exist on that integration
Exists on the integration but maybe in test mode, and you're using your live keys (or in live mode and you're using your test keys)

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 :)

Why does this CORS request to a google Drive Sheet fail in Firefox ? (works in Chrome)

I'm trying to request a google sheet from the client in javascript, using jquery ajax.
The following code works in Chrome but fails in Firefox.
Question : how can I get it to work in Firefox?
If it's a server configuration issue then does this mean it's impossible to link to google drive documents from a firefox client?
Here is the code:
var url = 'http://docs.google.com/spreadsheets/export?id=1-on_GfmvaEcOk7HcWfKb8B6KFRv166RkLN2YmDEtDn4&exportFormat=csv';
$.ajax({
url : url,
type : 'GET',
dataType : 'text',
success : function(res, status){
console.log('status : ' + status);
console.log(res);
},
error : function(res, status, error){
console.log('status : ' + status);
console.log(res);
console.log(error);
}
});
In Chrome I get a 307 response then a 200 with the desired data.
In Firefox I get a only a 200 response but with the error message something like "Access-Control-Allow-Origin header missing, Same Origin Policy does not allow to fetch this resource".
The problem is that docs.google.com does not set CORS headers on redirects. And Chrome is not following the specification by not enforcing that and therefore has a security bug of sorts.
docs.google.com is in Chrome's HSTS preload list. The request to http://docs.google.com is transparently rewritten to https://docs.google.com, so no redirect happens.
I assume this will resolve itself if Firefox pulls an updated copy of the HSTS preload list. As Anne notes, simply changing the link to https directly will solve your use case.
I found a workaround by configuring Google Drive slightly differently, and using JSONP :
1) In Google Drive, Publish on the web the document & set sharing options to Public
2) Export your data in JSON format with a JSON type link, it will look like : "http://spreadsheets.google.com/feeds/list/YOUR_FILE_ID/od6/public/values?alt=json&callback=myCallback". You need to append &callback=myCallback to use JSONP. You can use jQuery to make your JSONP call.
3) To use the data, you need to define the callback function specified in the url , in this case "myCallback"
I've mentioned a similar procedure in a different answer but I think it can be useful to mention it here as well since it directly relates to the problem I was facing.
#EnricoFerreguti you should replace YOUR_FILE_ID with your file ID. Example : https://spreadsheets.google.com/feeds/list/1-on_GfmvaEcOk7HcWfKb8B6KFRv166RkLN2YmDEtDn4/od6/public/values?alt=json from the http://misterfresh.github.io/react-drive-cms/ website .

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

:1 is being appended to my ajax requests with jQuery

I'm trying to access an external API from my website, and for some strange reason I am getting an ':1' appended to my ajax requests. Everything else seems to be right. BTW, I'm trying to access the Bing Images API using jQuery.
$.get('http://api.bing.net/json.aspx?callback=?',
{
AppId : <MYAPPID>,
Query : 'help',
Sources : 'Image'
},
imageResponseHandler,
'json'
);
I get this URL, which throws a syntax error in chrome console:
http://api.bing.net/json.aspx?callback=jsonp1329103936801&AppId<myappid>&Query=help&Sources=Image:1
The ':1' at the end brings up a 'not expecting token :' error. Where is it coming from? Removing the colon and pasting the url into my browsers gets me the json I want, but this seems to break before actually making the request.
Thanks,
Siegfried

Resources