Google People API - get contact details (batch) - google-api

Using Google People API, one can get a contact detail by its ID.
"https://people.googleapis.com/v1/" + id + "?key=" + <KEY> + "&personFields=addresses,clientData,emailAddresses,names,organizations,phoneNumbers,birthdays",
Is it possible to get such details in batch? I have a list of 100 contact ids and I want them to get at once as it'd be much faster.

In your situation, how about using the method of "Method: people.getBatchGet"? When this method is used, the 200 resource names (maximum number) can be retrieved by one API call. When this is used for your situation, it becomes as follows.
Sample curl command:
curl \
'https://people.googleapis.com/v1/people:batchGet?personFields=addresses%2CclientData%2CemailAddresses%2Cnames%2Corganizations%2CphoneNumbers%2Cbirthdays&resourceNames=people%2Fsample1&resourceNames=people%2Fsample2&resourceNames=people%2Fsample3' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
In above case, the unencoded endpoint is https://people.googleapis.com/v1/people:batchGet?personFields=addresses,clientData,emailAddresses,names,organizations,phoneNumbers,birthdays&resourceNames=people/sample1&resourceNames=people/sample2&resourceNames=people/sample3.
Also, you can test this with "Try this API". Ref
Reference:
Method: people.getBatchGet

Related

postman binary data-type detect and save in laravel request

In postman there is an option to send binary datatype in a api.
I am sending that in a api where but i am unable to detect that binary file in laravel request method.
curl --location --request POST 'http://192.168.*.*/api/v1/contact_us/save' \
--header 'Authorization: Bearer some_key' \
--header 'Content-Type: image/jpeg' \
--data-binary '#/Users/username/Desktop/filename.jpeg'
Above is my curl code generated in postman.
Although i am successfully getting this file when i request in multipart/form-data
I did see a question related to it but it is not the exact case
related question
If the HTTP request payload is purely a file (ie. not from a HTML form) then you can access it in Laravel using:
$request->getContent()

How do I send this multipart/form-data to a Web Service using Genexus?

The Following CUrl works perfectly whenever I test it:
curl --request PUT \
--url https://api.sandbox.URL_HERE/document-analysis/90471702021 \
--header 'Accept: application/json' \
--header 'Authorization: Bearer AUTH_TOKEN' \
--header 'Content-Type: multipart/form-data; boundary=---011000010111000001101001' \
--header 'api-version: 1.0' \
--form documentType=RG \
--form documentSide=FRONT \
--form 'image=data:image/jpeg;name=RG_Front.jpg;base64,/9j/4AAQSkZJRgABAQEAAQABAAD/4Tn0RXhpZgAATU0AKgAAAAgABgALAAIAAAAmAAAIYgESAAMAAAABAAEAAAExAAIAAAAmAAAIiAEyAAIAAAAUAAAIrodpAAQAAAABAAAIwuocAAcAAAgMAAAAVgAAEUYc6gAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8JeLF8wysb6N95+837vqfyr2KvwCwP8VH2ABmkb5RQGx2qNm8zhTj3rk5rH0xImduKSY7UP0NPHFMlXcpHTrWiE9j8eNcuLbT/FWpXcipPi/uC1uyNIANzjHHBIyDjOOKyLW8eOS7gNrCTdRF7O3RiESOLUbZY4IdzF41TcQC2R87bm5bmv0mK4xg4HpSKvvUuTvoP6nT7n5yXf7KPxc1ZZVu/Blg6SzNM6HWwgJBCoC6PvYJGCqqWIGScE1auP2SPi/N5/k6PpzPNGgaS81OKRvMRsrIw2FXO0BeRkjqa/RPb6mk9s5p8zBYOmj88ZP2Q/i2bGZY9G0a3U5aOFdV3m2YjD+QzIfJDDIKgkYPGOtQ/8MY/F545IF0/w9DaTFQYDqLHZGH3MrfJ+8LHGWfeeOMV+ie31PNJt96lTfYr6pTPz7uv2Mfi1eNMGj8OqZFYSTSavcOZN3396mMpg4U4CjGwY4zmP/hhv4pLkJN4XXdsORqFwJBIo4lRxFuRupwDt55Br9BiWVckcD0py4ZfahzYfVKZ8FzfsY/FqaczjVPCkcwiMcbLLKF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ut just to fit the comment field, but you get the idea.
I just have to send some info to the endpoint using HTTPClient but got stuck especially because Genexus says that the line is too big when I try to convert the image (1Mb) to a base64 string.
Has anyone gone through that?
It seems that the Web Service is expecting the new "multipart/form-data" instead of the old "application/x-www-form-urlencoded" for uploading files as explained here and the specification section for forms in HTML 4.01 is here. So, going to your question, I think that you can use the AddFile method of the HTTPClient data type (as explained here) to get your client working. Readink the wiki, it says:
In particular, if the content of the HttpClient message is multipart / form-data (given by Content-Type Header), then the AddFile method adds the file as multipart. In this case, the second parameter is needed to indicate the name of the variable that the file represents. Also, you have to necessarily precede your sentence with a header that specifies a specific Content-Type, like this:
&Httpclient.Addheader("Content-Type", !"multipart/form-data")
I say "I think" because I dindn't test myself, you can try and let us know if it works or not.

Azure Office 365 Management APIs

I am trying to get a response from Microsofts Office 365 Management API using bash curl commands-
I get the token like this-
TOKEN=$(curl -X POST "https://login.microsoftonline.com/$TENANTID/oauth2/token" -d "grant_type=client_credentials&client_id=$CLIENTID&client_secret=$ACCESSCODE&resource=$RESOURCEURL" | jq -r '.access_token')
And then use the token to fetch the data like this-
RESULT=`curl -X GET -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" https://manage.office.com/api/v1.0/$TENANTID/ServiceComms/Services`
I do get a token back with the first command, so that works fine and my tenant/client/resource strings are correct
But the second one always gives
{
"error":{
"code":"","message":"Authorization has been denied for this request."
}
}
I pretty sure I have access-
What am I missing?
Turns out the resource URL i was using did not match the URL i was requesting data from

GraphiQL - upload file

How can we upload files using in-browser GraphQL IDE GraphiQL, is that even possible ? (apart from base64 encoded string)
Once I have the file stream / file contents I can create a mulipart request and store on DB or some object-storage service.
But I am not able to figure it out how to provide the file input / how the schema would look like. Is it better to use graphql-upload with Curl request. Please suggest which is the optimal solution.
I was able to upload a file in my mutation input using Altair. You can use the Add files button to upload a file, then use the upload name on your mutation.
Guys just try Altair, saved me a lot of trouble and time. It has extension for chrome too, just like Apollo playground or graphiql, but with file upload option underneath the variables option.
Currently GraphIQL does not support file uploads. You can use an API tool to do this such as Postman, Insomnia or plan old cURL. The important distinction is that it needs to be a multi-part form upload.
Example request:
curl --request POST \
--url http://localhost:4000/ \
--header 'accept: application/json' \
--header 'accept-encoding: gzip, deflate, br' \
--header 'connection: keep-alive' \
--header 'dnt: 1' \
--header 'origin: http://localhost:4000' \
--form 'operations={"query": "mutation UploadFile($file: Upload!) { uploadFile(file: $file)}", "variables": { "file": null } }' \
--form 'map={ "nFile": ["variables.file"] }' \
--form nFile=#/tmp/testfile
Substitute /tmp/testfile in the request above with a path to the file you want to upload.

Unable to invoke Rally LBAPI WS from ruby rest-client program. Any

I have been able to query rally analytics API using DHC(Dev HTTP Client) with the following POST request
http://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1234/artifact/snapshot/query.js&API_Key=key123
and body
{
"find": {
"ObjectID": 4321
}
}
Is there any way I can do this from Ruby? I have using 'rest-client' but am only getting errors endlessly (400, 403, ....)
Has anyone been able to do this ?
Is this possible using curl?
It's possible using both curl and ruby. You need to set a ZSESSIONID header value equal to your API Key. Curl example here (randomized Workspace OID and API Key):
curl -X POST \
'https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/12345678910/artifact/snapshot/query' \
-H 'content-type: application/json' \
-H 'accept: application/json' \
-H 'ZSESSIONID: _m31qjdm43Ou74h0cACk28zgBUOPm50Xtna2PhQ2L22' \
--data '{"find":{"FormattedID": "DE9", "__At": "current"},"fields":true,"start":0,"pagesize":10,"removeUnauthorizedSnapshots":true}' \
--compressed
It is fairly straightforward to do in Ruby also. The following Gists:
Rally Lookback Connection Helper
Rally Lookback Query Example
Contain a Ruby connection helper for connecting to Rally's Lookback API. The second Gist contains an example of using the connection helper along with a hash representing a find query object. The Ruby example uses httpclient gem as opposed to rest-client gem, but the concept is the same.
Has this API changed ? We had a change in our username recently and since then, running the Query example returns {"_rallyAPIMajor":"2","_rallyAPIMinor":"0","Errors":["Not Found"],"Warnings":[]}
for all the queries.

Resources