Google Contacts API PUT Invalid XML Document - google-contacts-api

I am trying to update contact info (Nickname) through Google Contact API, but getting an Invalid XML Document error (400 Bad Request). The request that I am sending is documentation : https://developers.google.com/contacts/v3/#updating_contacts.
this is my request body:
<entry gd:etag="&quot;Qno-eTVSLit7I2A9XBJUF0kKRAY.&quot;">
<id>http://www.google.com/m8/feeds/contacts/cdatatester%40gmail.com/base/21aa268e8c9eea4c</id>
<updated>2019-01-17T15:52:03.451Z</updated>
<app:edited>2019-01-17T15:52:03.451Z</app:edited>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"></category>
<title>Elizabeth Bennet</title>
<content>Notes</content>
<link rel="http://schemas.google.com/contacts/2008/rel#photo" type="image/*" href="https://www.google.com/m8/feeds/photos/media/cdatatester%40gmail.com/21aa268e8c9eea4c"></link>
<link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/cdatatester%40gmail.com/full/21aa268e8c9eea4c"></link>
<link rel="edit" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/cdatatester%40gmail.com/full/21aa268e8c9eea4c"></link>
<gd:name>
<gd:fullName>Elizabeth Bennet</gd:fullName>
<gd:givenName>Altin2</gd:givenName>
<gd:familyName>Bennet</gd:familyName>
</gd:name>
<gContact:nickname>Altin</gContact:nickname>
<gd:email rel="http://schemas.google.com/g/2005#home" address="liz#gmail.com"></gd:email>
<gd:email rel="http://schemas.google.com/g/2005#work" address="liz#example.org"></gd:email>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#work" uri="tel:+1-206-555-1212">(206)555-1212</gd:phoneNumber>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#home" uri="tel:+1-206-555-1213">(206)555-1213</gd:phoneNumber>
<gd:structuredPostalAddress rel="http://schemas.google.com/g/2005#home">
<gd:formattedAddress>1600 Amphitheatre Pkwy
Mountain View
CA</gd:formattedAddress>
<gd:street>1600 Amphitheatre Pkwy</gd:street>
<gd:city>Mountain View</gd:city>
<gd:country code="CA">CA</gd:country>
</gd:structuredPostalAddress>
<gContact:userDefinedField key="Color" value="Green"></gContact:userDefinedField>
<gContact:userDefinedField key="Size" value="Medium"></gContact:userDefinedField>
<gContact:groupMembershipInfo deleted="false" href="http://www.google.com/m8/feeds/groups/cdatatester%40gmail.com/base/6"></gContact:groupMembershipInfo>
<gContact:groupMembershipInfo deleted="false" href="http://www.google.com/m8/feeds/groups/cdatatester%40gmail.com/base/782732538ae3faa4"></gContact:groupMembershipInfo>
</entry>
Is there anything wrong with my request? I cannot spot any error.

Related

Mail sending through gmail in Mule Flow

I am struggling with mail sending flow in mule, Getting below error:
Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=smtps://dummy.DevGroup:<password>#smtp.gmail.com, connector=SmtpsConnector
I have below configuration in my xml file (Updated with namespace declarations in the Mule XML):
<mule
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:twilio="http://www.mulesoft.org/schema/mule/twilio"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp"
xmlns:smtps="http://www.mulesoft.org/schema/mule/smtps"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/3.3/mule-smtp.xsd
http://www.mulesoft.org/schema/mule/smtps http://www.mulesoft.org/schema/mule/smtps/current/mule-smtps.xsd
http://www.mulesoft.org/schema/mule/twilio http://www.mulesoft.org/schema/mule/twilio/1.0/mule-twilio.xsd">
<service name="tool.muleservice.emailServiceintegration">
<inbound>
<inbound-endpoint ref="tool.endpoint.emailNotification"/>
</inbound>
<outbound>
<pass-through-router>
<outbound-endpoint ref="tool.smtp.endpoint.emailNotification"/>
</pass-through-router>
</outbound>
</service>
<smtps:endpoint name="tool.smtp.endpoint.emailNotification"
user="#[message.inboundProperties['userName']]"
password="#[message.inboundProperties['password']]"
host="smtp.gmail.com"
port="465"
from="dummy.DevGroup%40gmail.com"
transformer-refs="customEmailTransformer"
connector-ref="myTSLSMTPConnnector">
</smtps:endpoint>
<smtps:connector name="myTSLSMTPConnnector">
<smtps:tls-client path="../cacerts" storePassword="changeit" />
<smtps:tls-trust-store path="../cacerts" storePassword="changeit" />
</smtps:connector>
I updated the xml file as below content, to use smtp-gmail-connector given here
<service name="tool.muleservice.emailServiceintegration">
<inbound>
<inbound-endpoint
ref="tool.endpoint.emailNotification" />
</inbound>
<outbound>
<pass-through-router>
<!-- <outbound-endpoint ref="tool.smtp.endpoint.emailNotification"/> -->
<smtp:outbound-endpoint connector-ref="smtpGmailConnector"
subject="test msg"
address="smtps://#[message.inboundProperties['userName']]:#[message.inboundProperties['password']]#smtp.gmail.com"
responseTimeout="10000" doc:name="Send notification email" />
</pass-through-router>
</outbound>
</service>
<smtp:gmail-connector name="smtpGmailConnector"
contentType="text/html" fromAddress="iip.claims.test#gmail.com"
replyToAddresses="iip.claims.test#gmail.com" >
<smtp:header key="foo" value="bar" />
<smtp:header key="baz" value="boz" />
</smtp:gmail-connector>
But after this I am getting below error:
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:/myApp-component-config/component-config.xml]
Offending resource: mule-bootstrap-config.xml; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:/myApp-integration-config/tool-mule-bootstrap-config.xml]
Offending resource: URL [vfs:/D:/Software/JBoss/jboss-eap-7.2/standalone/deployments/myApp.war/WEB-INF/lib/tool-intrg.jar/myApp-component-config/component-config.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:/myApp-integration-config/tool-intrg-flows.xml]
Offending resource: URL [vfs:/D:/Software/JBoss/jboss-eap-7.2/standalone/deployments/myApp.war/WEB-INF/lib/tool-intrg.jar/myApp-integration-config/tool-mule-bootstrap-config.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 91 in XML document from URL [vfs:/D:/Software/JBoss/jboss-eap-7.2/standalone/deployments/myApp.war/WEB-INF/lib/tool-intrg.jar/myApp-integration-config/tool-intrg-flows.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 91; columnNumber: 67; The prefix "doc" for attribute "doc:name" associated with an element type "smtp:outbound-endpoint" is not bound.
at deployment.myApp.war//org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at deployment.myApp.war//org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at deployment.myApp.war//org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
at deployment.myApp.war//org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:235)
Any help will be appreciated.
There are many details missing however on rereading the issue I suspect you are not following the deprecated syntax <service> correctly by trying to use a current example. Since that syntax has been deprecated for 6+ years, I would advice to move to the more current <flow> definitions.
In case you are unable or unwilling to migrate, you need to define an endpoint outside the service and reference it you could try the following steps:
Ensure that the namespaces at the beginning of the file are correct. The error mentions that doc: is not recognized. Maybe the namespaces are outdated.
Ensure that the dependencies in the pom reference your Mule 3.9.x release and not an older version that may not define doc.
Try moving <smtp:outbound-endpoint> to a separate endpoint definition and reference it from the <pass-through-router> as in your original implementation.
Example:
<service name="tool.muleservice.emailServiceintegration">
<inbound>
<inbound-endpoint ref="tool.endpoint.emailNotification"/>
</inbound>
<outbound>
<pass-through-router>
<outbound-endpoint ref="tool.smtp.endpoint.gmailNotification"/>
</pass-through-router>
</outbound>
</service>
<smtps:endpoint name="tool.smtp.endpoint.gmailNotification"
connector-ref="smtpGmailConnector"
subject="test msg"
address="smtps://#[message.inboundProperties['userName']]:#[message.inboundProperties['password']]#smtp.gmail.com"
responseTimeout="10000" doc:name="Send notification email" >
</smtps:endpoint>
<smtp:gmail-connector name="smtpGmailConnector"
contentType="text/html" fromAddress="iip.claims.test#gmail.com"
replyToAddresses="iip.claims.test#gmail.com" >
<smtp:header key="foo" value="bar" />
<smtp:header key="baz" value="boz" />
</smtp:gmail-connector>
Finally if everything else fails you could try removing the doc:name attribute and see what happens.

unable to parse soap response using Azure API Management liquid template

I want to change the output format of the soap response, before passing it onto the client. I am using the soap pass-through as specified in the documentation https://azure.microsoft.com/en-ca/blog/soap-pass-through/
Soap service used in this example is hosted at
https://fazioapisoap.azurewebsites.net/FazioService.svc?singleWsdl
I am unable to extract the soap response in the liquid template. Soap response does get generated, however, there is no data.
Is there anything wrong with this code?
<policies>
<inbound>
<set-header name="Content-Type" exists-action="override">
<value>text/xml</value>
</set-header>
<set-body template="liquid">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header />
<soapenv:Body>
<tem:GetOpenOrders>
<!--Optional:-->
<tem:cust>{{body.Envelope.Body.GetOpenOrders.cust}}</tem:cust>
</tem:GetOpenOrders>
</soapenv:Body>
</soapenv:Envelope>
</set-body>
<base />
</inbound>
<backend>
<base />
</backend>
<outbound>
<set-body template="liquid">
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetOpenOrdersResponse xmlns="http://tempuri.org/">
<GetOpenOrdersResult xmlns:a="http://schemas.datacontract.org/2004/07/FazioAPISoap" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
{% for summary in body.Envelope.Body.GetOpenOrdersResponse.GetOpenOrdersResult.OrderSummary -%}
<a:OrderSummary><a:order_id>{{summary.order_id}}</a:order_id></a:OrderSummary>
{% endfor -%}
</GetOpenOrdersResult>
</GetOpenOrdersResponse>
</s:Body>
</s:Envelope>
</set-body>
<set-header name="Content-Type" exists-action="override">
<value>text/xml</value>
</set-header>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
You don't have to prefix the namespaces. This requests is valid
<set-body template="liquid">
<Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<GetOpenOrdersResponse xmlns="http://tempuri.org/">
<GetOpenOrdersResult xmlns:a="http://schemas.datacontract.org/2004/07/FazioAPISoap" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
{% for summary in body.Envelope.Body.GetOpenOrdersResponse.GetOpenOrdersResult.OrderSummary -%}
<OrderSummary>
<order_id>
{{summary.order_id}}
</order_id>
</OrderSummary>
{% endfor -%}
</GetOpenOrdersResult>
</GetOpenOrdersResponse>
</s:Body>
</s:Envelope>
</set-body>
I can see two potential problems with your request.
You might be missing SOAPAction header, example for submitOrder
<set-header name="SOAPAction" exists-action="override">
<value>http://tempuri.org/IFazioService/submitOrder</value>
</set-header>
Also you may want to set backend url and rewrite path to the resource (if APIM path is different than the SOAP service)
<set-backend-service base-url="{{s-iserve-store-inventory-backend-url}}" />
<rewrite-uri template="?" copy-unmatched-params="false" />

PHP - Create contact inside System Group: myContacts

I've a little question.
I want to create / update a contacts inside a system group,precisely myContacts group but unfortunately I can not.
This is my code:
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
<atom:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/>
<gd:name>
<gd:givenName>Surname</gd:givenName>
<gd:familyName>Name</gd:familyName>
<gd:fullName>Name Surname</gd:fullName>
</gd:name>
<gd:email rel="http://schemas.google.com/g/2005#work" primary="true" address="firstemail#gmail.com" />
<gd:phoneNumber rel="http://schemas.google.com/g/2005#home">1234567891</gd:phoneNumber>
<gContact:groupMembershipInfo deleted="false" href="http://www.google.com/m8/feeds/groups/email#gmail.com/base/myContacts"/>
How I can create contact inside that system Group?

Getting issue in making JSON request from xml request of SAP

My Requirement is to create a JSON for the below xml, and send as POST request to SAPNetweaver adapter.
SAP End point
URI: /sap/opu/odata/sap/ZPM_MOBILE_SRV/WOHeaderSet
Method: POST
Payload: 1 operation, 2 materials
XML request which contain two payload operations and material.
1. operation : WOHeaderOperation
2. materail : WOHeaderMaterial
this code basically contain two section one WOHeaderOperation and second for WOHeaderMaterial
<?xml version="1.0" encoding="UTF-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<atom:content type="application/xml">
<m:properties>
<d:Aufpl>1000000053</d:Aufpl>
<d:GltrpTms>1425887760</d:GltrpTms>
<d:GstrpTms>1425887760</d:GstrpTms>
<d:Auart>PM02</d:Auart>
<d:Ktext>Test for MAMBO 2</d:Ktext>
<d:Iwerk>KACT</d:Iwerk>
<d:Ingrp>KP</d:Ingrp>
<d:Gewrk>10000359</d:Gewrk>
<d:Tplnr>KAC-0P5010-PM1</d:Tplnr>
<d:Arbpl>10000359</d:Arbpl>
</m:properties>
</atom:content>
<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/WOHeaderOperation" type="application/atom+xml;type=feed" title="WOHeaderOperation">
<m:inline>
<atom:feed>
<atom:entry>
<atom:content type="application/xml">
<m:properties>
<d:Vornr>0010</d:Vornr>
<d:Ltxa1>Operation 1</d:Ltxa1>
<d:Indet>2</d:Indet>
</m:properties>
</atom:content>
</atom:entry>
</atom:feed>
</m:inline>
</atom:link>
<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/WOHeaderMaterial" type="application/atom+xml;type=feed" title="WOHeaderMaterial">
<m:inline>
<atom:feed>
<atom:entry>
<atom:content type="application/xml">
<m:properties>
<d:Vornr>0010</d:Vornr>
<d:Posnr>0010</d:Posnr>
<d:Matnr>340</d:Matnr>
<d:Werks>KACT</d:Werks>
<d:Bdmng>7.000</d:Bdmng>
<d:Meins>PCE</d:Meins>
<d:Postp>L</d:Postp>
</m:properties>
</atom:content>
</atom:entry>
<atom:entry>
<atom:content type="application/xml">
<m:properties>
<d:Vornr>0010</d:Vornr>
<d:Posnr>0020</d:Posnr>
<d:Matnr>338</d:Matnr>
<d:Werks>KACT</d:Werks>
<d:Bdmng>10.000</d:Bdmng>
<d:Meins>PCE</d:Meins>
<d:Postp>L</d:Postp>
</m:properties>
</atom:content>
</atom:entry>
<atom:entry>
<atom:content type="application/xml">
<m:properties>
<d:Vornr>0010</d:Vornr>
<d:Posnr>0030</d:Posnr>
<d:Matnr>336</d:Matnr>
<d:Werks>KACT</d:Werks>
<d:Bdmng>10.000</d:Bdmng>
<d:Meins>PCE</d:Meins>
<d:Postp>L</d:Postp>
</m:properties>
</atom:content>
</atom:entry>
</atom:feed>
</m:inline>
</atom:link>
</atom:entry>
If you want it to be JSON, request it as such:
GET /sap/opu/odata/sap/ZPM_MOBILE_SRV/WOHeaderSet?$format=json
But Gateway will accept both JSON and XML so there is really no need other than your own preference.

Google Apps Script-How to get value from XmlDocument?

I am trying to get all calender details of all users. I got this successfully but its return result in Xml format as following:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>http://www.google.com/calendar/feeds/email-id/private/full</id>
<updated>2012-02-15T15:34:49.000Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/>
<title type="text">email-id</title>
<subtitle type="text">email-id</subtitle>
<link href="https://www.google.com/calendar/embed?src=email-id" rel="alternate" type="text/html"/>
<link href="https://www.google.com/calendar/feeds/email-id/private/full" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/>
<link href="https://www.google.com/calendar/feeds/email-id/private/full" rel="http://schemas.google.com/g/2005#post" type="application/atom+xml"/>
<link href="https://www.google.com/calendar/feeds/email-id/private/full/batch" rel="http://schemas.google.com/g/2005#batch" type="application/atom+xml"/>
<link href="https://www.google.com/calendar/feeds/email-id/private/full?max-results=25" rel="self" type="application/atom+xml"/>
<author>
<name>Name</name>
<email>email-id</email>
</author>
<generator uri="http://www.google.com/calendar" version="1.0">Google Calendar</generator>
<openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:totalResults>
<openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:startIndex>
<openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">25</openSearch:itemsPerPage>
<gCal:timezone value="Europe/Dublin" xmlns:gCal="http://schemas.google.com/gCal/2005"/>
<gCal:timesCleaned value="0" xmlns:gCal="http://schemas.google.com/gCal/2005"/>
<entry>
<id>http://www.google.com/calendar/feeds/email-id/private/full/vj39u2qedgphrp10nah92h6ho0</id>
<published>2012-02-15T11:21:54.000Z</published>
<updated>2012-02-15T11:21:54.000Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/>
<title type="text">Test Appointment</title>
<content type="text">This is a test description</content>
<link href="https://www.google.com/calendar/event?eid=dmozOXUycWVkZ3BocnAxMG5haDkyaDZobzAgcmFoaW1AZGFtc2" rel="alternate" title="alternate" type="text/html"/>
...
</entry>
</feed>
I want to get the value of title and content.Please share me with the solution
Thank you
Use the built-in Xml service https://developers.google.com/apps-script/service_xml.
With this sevice you can parse thru the xml document.