Error About Google Vault API with python program - google-vault-api

Im using Google Vault API from the python program.
Using method is [Method: matters.exports.create]
reference
https://developers.google.com/vault/reference/rest/v1/matters.exports/create
Using python library is google-api-python-client.
https://github.com/googleapis/google-api-python-client
result = service.matters().exports().get(matterId=matter_id, exportId=vault_extraction.export_id, alt='json').execute()
I executed that python program, and got an API error response.
"<HttpError 400 Request contains an invalid argument>"
I'd like to know why i got the error, and how to resolve this error.
thanks.

Related

Microsoft Graph: Getting 400 Bad Request when trying to fetch mailboxSettings

I have followed this tutorial and have implemented Microsoft login via OAuth and Azure. Also, I have fetched data from Microsoft Graph to store in my database.
Here is a code sample to fetch data using Microsoft Graph:
$graph = new Graph();
$graph->setAccessToken($accessToken->getToken());
$user = $graph->createRequest('GET', '/me?$select=id,displayName,givenName,surName,mail,mobilePhone,jobTitle,userPrincipalName')
->setReturnType(Model\User::class)
->execute();
The code works fine and I get my desired data.
However, when I change the url from '/me?$select=id,displayName,givenName,surName,mail,mobilePhone,jobTitle,userPrincipalName' to '/me?$select=id,displayName,givenName,surName,mail,mobilePhone,jobTitle,userPrincipalName,mailboxSettings', I am getting this error:-
Error Code:- 400| Error Message:- Client error: `GET https://graph.microsoft.com/v1.0/me?$select=id,displayName,givenName,surName,mail,mobilePhone,jobTitle,userPrincipalName,mailboxSettings` resulted in a `400 Bad Request` response: { "error": { "code": "AuthenticationError", "message": "Error authenticating with resource", "innerErr (truncated...) | Error Location:- Line No. 113 in file C:\xampp7.2\htdocs\kaec\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php
As you can see, I am getting the 400 Bad Request error only when I am adding 'mailboxSetttings' in the query string of the url.
Why am I getting this error? The tutorial itself has used 'mailboxSetttings' in their sample code?
PS: Two days ago, it worked absolutely fine when I used 'mailboxSetttings' in the query. But today, I am getting 400 - Bad Request.
Check if you have MailboxSettings.Read and MailboxSettings.ReadWrite permissions to be able to read, update, create, and delete your mailbox settings.
I agree with #user2250152 answer, at first I used an access token which doesn't with the scope of MailboxSettings.ReadWrite, and I called the api
'https://graph.microsoft.com/v1.0/me?$select=id,displayName,givenName,surName,mail,mobilePhone,jobTitle,userPrincipalName,mailboxSettings'
it returns 403 error(not the same as yours 400), I checked the api document and found that the 'mailboxSettings' property really exists but even I used beta version of the api I still can't find it in response. So I tried to add api permission when generate the access token, finally it worked for me.
I think you can debug your program to check if the access token you used to call the api has the scope of 'MailboxSettings.ReadWrite', just decode the token and you can see it in the claim "scp", because you said that your programs run absolutely fine before. So maybe you've added more other scopes(not belong to graph) when generate access token.

npm sync-request: NetworkError: Failed to execute 'send' on 'XMLHttpRequest'

I'm studying about ReactJS and during my research I got stuck in middle of this untraceable issue. The idea is to present information on browser screen fetched from Database. I've chosen WebAPI to serve as a channel for communicating with database. The API implementation is working as expected, I tested it using Postman.
But I'm encountering the subjected error when I try to access API through Reducer (React-Redux implementation), please refer below screenshot.
It seems to me a CORS (Cross-Origin Resource Sharing) issue, as both API & ReactJS app running on localhost using different ports, but I'm not sure. In either case, please help me get to the solution.

Google Cloud Pub/Sub node library error parsing

I'm trying to handle error responses returned from the Google Cloud Pub/Sub api using their node client library. From what I can see, if you use their REST API directly (ie. not through the client library) they return common HTTP error codes:
https://cloud.google.com/pubsub/docs/reference/error-codes
However, their client library returns RPC style errors that do not adhere to http status code conventions.
I have a worker that is processing these responses and is expecting responses to conform to standard http response conventions. Does anyone know if there is a way to intercept the actual HTTP response that the client is handling and extract a status code from it? Alternatively, is there documentation somewhere listing out the potential RPC errors the node client can return so I can set up a mapping from them to http codes?
Thanks!
FYI this got answered as a Github issue here: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2761#issuecomment-348358474

Getting CORS error When Using Spotify Open APIs

I'm getting CORS error while trying to get some data through Spotify's Open APIs such as API/v1/search?type=album&q=... and API/v1/albums/{id} in a Simple Angular 4 Application that searches for albums with a Query then tries to show that specific album Information.
I assume that these two APIs are open and don't need any kind of authorization. So How can I get data from these two when there's no JSONP method available without getting CORS error and without Authorization?
Passing client_id doesn't help I'm afraid.
As no one posted a proper answer, I ended up writing and using a simple wrapper over Spotify's API. Everything's working now! No more darn CORS errors or anything! :)

Open Graph Action POST fails when called thru a google app engine based unpaid instance

urlopen fails with a 500 code and '{"error_code":1,"error_msg":"An unknown error occurred"}' error from Facebook when posting an Open Graph Action. I can get the code to work with other posts (e.g. posting a comment on a status using the graph API works fine). I can also get this action-post to work using curl. So this seems like a urllib2.urlopen issue when posting a form-data with a URL as one of the values.
Graph api post that works with curl :
curl -F 'access_token=nnnnnn' -F 'object=https://abc.com/123' \
'https://graph.facebook.com/me/namespace:action' -k
Same Graph api post thru urllib2 which gives the error :
from urllib2 import urlopen, Request, URLError
request = Request (url='http://graph.facebook.com/me/namespace:action';,
data = urllib.urlencode(
{'object':'https://abc.com/123',
'access_token':'nnnnnnnn'
},
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
)
response = urlopen (request)
What could I be doing wrong ? (I am new to urllib2.urlopen. Btw, I originally tried urlfetch.fetch thru the urlfetch python module. That did not work either). I am using this thru goole app engine.
After a fair amount of digging/trial-error, finally managed to solve this.
This is not an issue with urllib urlopen, but more of a Google App Engine nuance where when an action post on an open Graph URL is called - it causes Facebook to trigger a 'get' on the Object URL (synchronously).
So essentially the get is being called on app engine app while an active instance is already calling the FB graph URL. I am currently using an unpaid instance and this is causing an unexpected behavior such that FB to fails the OG post (I see the get on the logs going thru successfully, while the active post, so not sure what causes FB to fail - anybody with an insight, please share).
I got around this by 'taskqueue'ing urlopen/OG-action-post - and when this is called the second time (FB apparently caches the object the first time) it succeeds.
If anybody needs more details, get in touch and am more than happy to save you all the time and pain that I have already gone thru..

Resources