Fetching select attributes from Google Contact API - google-contacts-api

While working with https://developers.google.com/google-apps/contacts/v3/reference, I haven't figured out a way yet to ONLY have Google return gd$email & gd$name instead of the following it returns by default.
["id", "gd$etag", "updated", "app$edited", "category", "title", "link", "gd$email", "gd$name"]
For our business use case, we only need these two attributes, having all the above in the response increases the response Pay Load and thus response time.
Any leads ?

You can change the response you get with contacts API. I tried for retrieving all the contacts, but to include only email and phone number in the response.
Here is the request https://www.google.com/m8/feeds/contacts/guntupalliswathi#gmail.com/full ?fields=entry/gd:email,entry/gd:phoneNumber(I tried in oauth playground)
Response:
<entry>
<gd:email rel="http://schemas.google.com/g/2005#other" address="xxxx#domain.com" primary="true"/>
</entry>
<entry>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#mobile" uri="tel:+91-0000-000-000"> </gd:phoneNumber>
</entry>
<entry>
<gd:email rel="http://schemas.google.com/g/2005#other" address="yyyy#domain.com" primary="true"/>
</entry>
<entry>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#mobile">(000) 000-0001</gd:phoneNumber>
</entry>
Let me know if your issue is not resolved.

For JSON response, you can supply field list as follows:
https://www.google.com/m8/feeds/contacts/default/full/?alt=json&fields=feed(entry(gd$name(gd$fullName))),feed(entry(gd$email(address)))
This will give you just full name and email per contact. Hope this works.

Related

PostMan: How can I copy an array/segment from one response to the next request?

first post on here!
I have been playing around with postman automation and managed to copy over ID strings and FAB Id's.
I have seen similar questions asked but didn't quite highlight how I was hoping to do it...
Availability Response;
<SessionInfo FABSessionId="FAB123456789"/>
<VehicleSearchResponse Success="true" ModifiedRequest="false">
<ViewInfo Offset="0" Length="30"/>
<ResultSetInfo SortCode="cost" SortAscending="true" MaxItems="900" NumItems="30"/>
<Vehicles>
<Vehicle StartDate="20181002" EndDate="20181006" PickUpPoint="XXX" DropOffPoint="XXX">
<Image URL="https://picture.net/example.jpg"/>
<MoreInfoTexts>
<MoreInfo Header="..."/>
<MoreInfo Header="..."/>
<MoreInfo Header="..."/>
</MoreInfoTexts>
<PickUpDepotDetails Telephone="012345 67890">
<Address Address1="..." CityOrTown="..." Country="..."/>
</PickUpDepotDetails>
<DropOffDepotDetails Telephone="012345 67890">
<Address Address1="..." CityOrTown="..." Country="..."/>
</DropOffDepotDetails>
</Vehicle>
........
</Vehicles>
</VehicleSearchResponse>
See above... I want to be able to copy the whole "Vehicle" segment from the availability response to the costing request... It is an array so there is 20 other results below .......
Costing Request:
<Itinerary EndDate="20181006" ItineraryId="V!XXX!12345!ABC123!XXX!ABC321!XXX" StartDate="20181002">
<Vehicles>
{{vehicleSetter}}
</Vehicles>
<OptionalExtras>
So the whole Vehicle - /Vehicle segment needs to be copied to {{vehicleSetter}}.
Is there a way to do this using similar (Costing) Pre-RQ scripts to;
pm.globals.get("fabSessionSetter");
pm.globals.get("vehicleSetter");
and maybe something in (Avail.) Tests script like
pm.globals.set("vehicleSetter", jsonObject.FAB_VehicleAvailRS.VehicleSearchResponse.Vehicles.Vehicle[2]);
Let me know if you need any more information... Thanks!
First of all, I would ask devs to use json type data for passing to instead of XML. it's much more convenient, I went this way on the begging of the development of a new project, it brought me many benefits. But in case it's possible in your case.
it's not necessary to use global variables.Environment variables are enough.
But try this, I never did it, but perhaps it will help you.
https://github.com/cheeriojs/cheerio
https://www.w3schools.com/xml/xpath_syntax.asp
I think I had a similar problem to you, having to convert json into xml, either way I had a fantastic response from Sivcan Singh
Convert XML to JSON for extracting data then convert JSON back to XML in Postman

How to change the parameters of nuxeo

I have a problem with Nuxeo, when I want to import my files with their attachements. It's necessary to adopt the parameters of The nuxeo CSV. For example : They define "dc:title" for title and "dc:description" for description.
here is how it works :
"name","type","dc:title","dc:description","file:content","dc:creator"
"nuxeo-csv-userdoc","File","Nuxeo CSV User documentation","This is the user guide for Nuxeo CSV","C:/../nuxeo-csv-userdoc.pdf","user"
My file is different, and I want to choose my parameters. For example, I have a date, society name, supplier, ID...which is different from what suggest Nuxeo.
Do you have any idea how to do this.
"Type","Title","Society","Year","ID","Path","supplier"
"RAPPORT","CENTRIFUGAL PUMPS","EMTECH-E LIST OF PARTS","2005","1767","file.pdf","XY"
Thanks
You must map the import with the custom type that you defined. Have you read https://doc.nuxeo.com/nxdoc/how-to-enable-csv-import-on-a-custom-document-type/ ?
you'll probably want to enable CSV import on the document types you defined, either in Studio or with some code. Here is how to do that.
(...)
<require>org.nuxeo.ecm.platform.actions</require>
<extension target="org.nuxeo.ecm.platform.actions.ActionService"
point="filters">
<filter id="importFile" append="true">
<rule grant="true">
<permission>AddChildren</permission>
<type>YourCustomTypeID</type>
</rule>
</filter>
</extension>

How to get JAXB output to have namespace included with the child node with no prefix?

God knows I searched the forum for an answer, but didn't see any.
This is the simplified XML my JAXB code reads. There are 2 namespaces involved. xyz and abc. These two are defined in two different schema files. And xjc generates two different packages for them. The following file is nicely read into those classes and can even write it.
<xyz:xyz xsi:schemaLocation="urn:xyz xyz.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xyz="urn:xyz">
<session>
<App xsi:schemaLocation="urn:abc abc.xsd" xmlns="urn:abc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AppItem att1="1234"/>
</App>
</session>
</xyz:xyz>
This is how it writes it.
<ns3:xyz xmlns:ns2="urn:abc" xmlns:ns3="urn:xyz">
<session>
<ns2:App>
<ns2:AppItem att1="1234"/>
</ns2:App>
</session>
</ns3:xyz>
Now i know about NamespacePrefixMapper and I can change ns2 and ns3 to the values I want. And I want this. Basically I want to main the original form of the XML. The App element should have all its information contained in itself and not create a prefix.
<xyz:xyz xmlns:xyz="urn:xyz">
<session>
<App xsi:schemaLocation="urn:abc abc.xsd" xmlns="urn:abc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AppItem att1="1234"/>
</App>
</session>
</xyz:xyz>
Does anyone have any clue as to how to achieve this? Seems like some setting in AppType.java should tell the writer to not update root element with prefix.

Amazon Product API: "Your request is missing a required parameter combination" on Blended ItemSearch

I'm having some problems trying to do an ItemSearch on the Blended index using the Amazon Product API.
According to the documentation, Blended requests cannot specify the MerchantId parameter - and indeed, if I try to include it I get an error telling me so. However, when I don't include it, I get an error telling me that my request is missing a required parameter combination and that a valid combination includes MerchantId... what the hell?
The failing requests are being sent as part of batches with other requests that are succeeding. I'm using REST to send my requests, so here's an example:
http://ecs.amazonaws.com/onca/xml?AWSAccessKeyId=-------------&
ItemSearch.1.Keywords=Mates%20of%20State&
ItemSearch.1.MerchantId=Amazon&
ItemSearch.1.SearchIndex=DVD&
ItemSearch.2.Keywords=teaching%20Lily%20various%20computer%20related%20skills&
ItemSearch.2.SearchIndex=Blended&
ItemSearch.Shared.Availability=Available&
ItemSearch.Shared.Condition=All&
ItemSearch.Shared.ResponseGroup=Small%2CSalesRank%2CImages%2COfferSummary%2CSimilarities&
Operation=ItemSearch%2CSimilarityLookup&
Service=AWSECommerceService&
SimilarityLookup.1.ItemId=B000FNNHZ2&
SimilarityLookup.2.ItemId=B000EQ5UPU&
SimilarityLookup.Shared.Availability=Available&
SimilarityLookup.Shared.Condition=All&
SimilarityLookup.Shared.MerchantId=Amazon&
SimilarityLookup.Shared.ResponseGroup=Small%2CSalesRank%2CImages%2COfferSummary&
Timestamp=2010-04-02T17%3A18%3A05Z&
Signature=----------------
Here's the XML response:
<Items xmlns="http://webservices.amazon.com/AWSECommerceService/2005-10-05">
<Request>
<IsValid>False</IsValid>
<ItemSearchRequest>
<Availability>Available</Availability>
<Condition>All</Condition>
<Keywords>teaching Lily various computer related skills</Keywords>
<ResponseGroup>Similarities</ResponseGroup>
<ResponseGroup>SalesRank</ResponseGroup>
<ResponseGroup>OfferSummary</ResponseGroup>
<ResponseGroup>Small</ResponseGroup>
<ResponseGroup>Images</ResponseGroup>
<SearchIndex>Blended</SearchIndex>
</ItemSearchRequest>
<Errors>
<Error>
<Code>AWS.MissingParameterCombination</Code>
<Message>Your request is missing a required parameter combination. Required parameter combinations include MerchantId, Availability.</Message>
</Error>
</Errors>
</Request>
</Items>
Any ideas as to what I'm doing wrong?
I seem to have solved this by removing both the Availability and Condition parameters. I'd ideally prefer to be able to filter by availability, but at least it's working.

Google geocoding service returns response for fake address

I'm using the google geocoding service to validate that a city name (plus region and country) that has been entered in our system exists, and to get the lat/long.
However, I'm finding that it seems to 'guess' if you make a typo, and returns an response even if you made an error.
For instance, a request for "Beverton, Ontario, Canada" returns the lat/long for Beaverton, with no indication that you provided the wrong city name.
I'm using the CSV response type, and am getting the 200 response code.
Can I either prevent the service from doing this, or, better yet, find out if it has?
Edit: to clarify ... Google is correcting the input (when I would expect it to just fail) and I need to know if it has done this.
There isn't any way for the geocoder to let you know if it thinks you had a typo. I agree with Saul's answer, that your best bet is to check your query against the response.
I just wanted to point out that you'll have to check several elements of your input against several of the response values, in order to find the elements that should match up. In this case, "Beaverton" was found inside of "DependentLocalityName".
<?xml version="1.0" encoding="UTF-8" ?>
<kml xmlns="http://earth.google.com/kml/2.0"><Response>
<name>Beverton, Ontario, Canada</name>
<Status>
<code>200</code>
<request>geocode</request>
</Status>
<Placemark id="p1">
<address>Beaverton, Brock, ON, Canada</address>
<AddressDetails Accuracy="4" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><Country><CountryNameCode>CA</CountryNameCode><CountryName>Canada</CountryName><AdministrativeArea><AdministrativeAreaName>ON</AdministrativeAreaName><SubAdministrativeArea><SubAdministrativeAreaName>Durham Regional Municipality</SubAdministrativeAreaName><Locality><LocalityName>Brock</LocalityName><DependentLocality><DependentLocalityName>Beaverton</DependentLocalityName></DependentLocality></Locality></SubAdministrativeArea></AdministrativeArea></Country></AddressDetails>
<ExtendedData>
<LatLonBox north="44.4502166" south="44.4183470" east="-79.1199562" west="-79.1839858" />
</ExtendedData>
<Point><coordinates>-79.1519710,44.4342840,0</coordinates></Point>
</Placemark>
</Response></kml>
Update:
This may be impossible to actually implement. If your input is "Beverton, Ontario, Canada", how do you know which of those three words to check for? Two of them will match up just fine. What if they're entered in a different order?
Is it responding with a "200 Success Code"? There's a chance that it might be giving you a different status code.
Here are the different status codes google returns: http://code.google.com/apis/maps/documentation/reference.html#GGeoStatusCode
NOTE: See the answer by #Chris B above. As Chris points out, this may be impossible to implement.
Do you have to use the CSV response type? If not, the other response types such as KML provide enough details to determine the location that the coordinates refer to. You could verify your input against the response's LocalityName element.
<kml xmlns="http://earth.google.com/kml/2.0">
<Response>
<name>1600 amphitheatre mountain view ca</name>
<Status>
<code>200</code>
<request>geocode</request>
</Status>
<Placemark>
<address>
1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA
</address>
<AddressDetails Accuracy="8">
<Country>
<CountryNameCode>US</CountryNameCode>
<AdministrativeArea>
<AdministrativeAreaName>CA</AdministrativeAreaName>
<SubAdministrativeArea>
<SubAdministrativeAreaName>Santa Clara</SubAdministrativeAreaName>
<Locality>
<LocalityName>Mountain View</LocalityName>
<Thoroughfare>
<ThoroughfareName>1600 Amphitheatre Pkwy</ThoroughfareName>
</Thoroughfare>
<PostalCode>
<PostalCodeNumber>94043</PostalCodeNumber>
</PostalCode>
</Locality>
</SubAdministrativeArea>
</AdministrativeArea>
</Country>
</AddressDetails>
<Point>
<coordinates>-122.083739,37.423021,0</coordinates>
</Point>
</Placemark>
</Response>
</kml>