ColdFusion CFHTTP Call To Create Google Calendar Event - http

I have implement most of the API calls using CFHTTP All is working fine.
I am using below code to create google calendar event.
Every parameter passed to it correct (validated). but with cfhttp it is not getting sent.
I got error of Filecontent
{ "error":
{ "errors": [
{ "domain": "global",
"reason": "required",
"message": "Missing end time."
} ],
"code": 400, "message": "Missing end time."
}
}
Code
<cfset title=eventTitle>
<cfset curlPost = StructNew()>
<cfset curlPost['summary'] = eventTitle>
<cfif eventType EQ 'FIXED-TIME'>
<cfset startTime = Replace(eventStartTime," ","T") & ":00">
<cfset endTime = Replace(eventEndTime," ","T") & ":00">
<cfset eventDate = "">
<cfset allDay = 0>
<cfset curlPost['start']['dateTime'] = startTime>
<cfset curlPost['start']['timeZone'] = data.value>
<cfset curlPost['end']['dateTime'] = endTime>
<cfset curlPost['end']['timeZone'] = data.value>
<cfelse>
<cfset startTime = "">
<cfset endTime = "">
<cfset eventDate = eventDate>
<cfset allDay = 1>
<cfset curlPost['start']['date'] = eventDate>
<cfset curlPost['end']['date'] = eventDate>
</cfif>
<cfdump var="#serializeJSON(curlPost)#">
<cfdump var="#curlPost#">
<cfhttp url="https://www.googleapis.com/calendar/v3/calendars/primary/events" method="post" result="httpResponse">
<cfhttpparam type="header" name="Content_Type" value="application/json">
<cfhttpparam type="header" name="Authorization" value="Bearer #session.access_token#" />
<cfhttpparam type="body" value="#serializeJSON(curlPost)#">
</cfhttp>

Related

Could not store Alpha-Code Remarks, Response status=Skipped

Adding Alpha-Coded remarks return SKIPPED status and remarks were not stored in the booking.
<stl19:UpdateReservationRS xmlns:stl19=http://webservices.sabre.com/pnrbuilder/v1_19 xmlns:ns6=http://services.sabre.com/res/orr/v0 xmlns:or114=http://services.sabre.com/res/or/v1_14 xmlns:raw=http://tds.sabre.com/itinerary xmlns:ns4=http://webservices.sabre.com/pnrconn/ReaccSearch Version="1.19.0">
<stl19:Success>OK</stl19:Success>
<stl19:Results>
<stl19:UpdateResult UpdateId="FE54E6B3-6529-492F-9579-392B56D6224B" Status="SKIPPED">
<stl19:Item id="4" op="C" />
</stl19:UpdateResult>
</stl19:Results>
</stl19:UpdateReservationRS>

WSDL request, SOAP in R

I want to use webservice feature of a website by using SOAP approach.
The methods below are the things written in the manual ;
WSDL Address: http://dev.gittigidiyor.com:8080/listingapi/ws/CategoryService?wsdl
Service Method Signature:
CategoryServiceResponse getCategories(int startOffSet, int rowCount, boolean withSpecs, boolean withDeepest, boolean withCatalog, String lang)
Request Example
<cat:getCategories>
<startOffSet>0</startOffSet>
<rowCount>4</rowCount>
<withSpecs>true</withSpecs>
<withDeepest>true</withDeepest>
<withCatalog>true</withCatalog>
<lang>tr</lang>
</cat:getCategories>
Here is what I have tried in R.
library(RCurl)
headerFields =
c(Accept = "text/xml",
'Content-Type' = "text/xml; charset=utf-8",
SOAPAction = "")
body <- '<cat:getCategories>
<startOffSet>0</startOffSet>
<rowCount>4</rowCount>
<withSpecs>true</withSpecs>
<withDeepest>true</withDeepest>
<withCatalog>true</withCatalog>
<lang>tr</lang>
</cat:getCategories>'
curlPerform(url = "http://dev.gittigidiyor.com:8080/listingapi/ws/CategoryService?wsdl",
httpheader = headerFields,
postfields = body
)
But at the end, only output I have is that ;
OK
0
However, it should be like that wrt the manual ;
<cat:getCategoriesResponse xmlns:cat="http://category.anonymous.ws.listingapi.gg.com">
<return>
<ackCode>success</ackCode>
<responseTime>29/06/2010 13:39:19</responseTime>
<timeElapsed>2 ms</timeElapsed>
<categoryCount>3849</categoryCount>
<categories>
<category hasCatalog="false" deepest="false">
<categoryCode>a</categoryCode>
<categoryName>Antikalar & Sanat</categoryName>
</category>
<category hasCatalog="false" deepest="false">
<categoryCode>aa</categoryCode>
<categoryName>Antika Ahşap Objeler</categoryName>
<specs>
<spec type="Combo" name="Menşei (Orijin)">
<values>
<value>Avrupa</value>
<value>Osmanlı</value>
<value>Türkiye</value>
<value>Uzakdoğu</value>
<value>Diğer</value>
<value>Rusya</value>
</values>
</spec>
<spec type="Combo" required="true" name="Kondisyon">
<values>
<value>Yüksek</value>
<value>Orta</value>
<value>Düşük</value>
</values>
</spec>
<spec type="Combo" required="true" name="Durumu">
<values>
<value>Yeni</value>
<value>Kullanılmış</value>
<value>Diğer</value>
</values>
</spec>
<spec type="Combo" required="true" name="Antika / Modern">
<values>
<value>Antika</value>
<value>Modern</value>
</values>
</spec>
<spec type="Combo" name="Dönemler">
<values>
<value>1800 öncesi</value>
<value>1800 - 1849</value>
<value>1850 - 1899</value>
<value>1900 - 1940</value>
<value>1940 sonrası</value>
</values>
</spec>
</specs>
</category>
<category hasCatalog="false" deepest="true">
<categoryCode>az</categoryCode>
<categoryName>Diğer Antikalar & Sanat</categoryName>
</category>
<category hasCatalog="false" deepest="false">
<categoryCode>b</categoryCode>
<categoryName>Bilgisayar</categoryName>
<specs>
<spec type="Combo" required="true" name="Durumu">
<values>
<value>Yeni, Açılmamış Kutusunda</value>
<value>Kullanılmış</value>
<value>Yeni, Kutusuz</value>
</values>
</spec>
</specs>
</category>
</categories>
</return>
</cat:getCategoriesResponse>
What am I missing? Can you help please?
This may help you,
library(RCurl)
headerFields = c(Accept = "text/xml",
'Content-Type' = "text/xml; charset=utf-8", SOAPAction = "")
body <- '<cat:getCategories>
<startOffSet>0</startOffSet>
<rowCount>4</rowCount>
<withSpecs>true</withSpecs>
<withDeepest>true</withDeepest>
<withCatalog>true</withCatalog>
<lang>tr</lang>
</cat:getCategories>'
reader <- basicTextGatherer()
curlPerform(url = "http://dev.gittigidiyor.com:8080/listingapi/ws/CategoryService?wsdl",
httpheader = headerFields,
postfields = body,
writefunction = reader$update
)
xml <- reader$value()
xml

How to resolve this error - Uncaught Error: '2016-' is not a correct date, datetime nor time

I got the following part of code from Odoo community reference website for creating birthday calendar mark ups
.PY file
class birthday_report(osv.osv):
_name = "birthday.report"
_auto = False
_columns = {
'name': fields.many2one('hr.employee','Employee', readonly=True),
'dob' : fields.date('Birthday', readonly=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'birthday_report')
cr.execute("""
create or replace view birthday_report as (
select
h.id as id,
h.id as name,
concat(concat(date_part('Year',current_date),'-'),to_char(h.birthday, 'mm-dd')) as dob
from
hr_employee as h
join
resource_resource as r
on
h.resource_id=r.id
where r.active ='t'
)
""")
birthday_report()
.XML file
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_birthday_report_calendar" model="ir.ui.view">
<field name="name">Employee Birthday</field>
<field name="model">birthday.report</field>
<field name="arch" type="xml">
<calendar string="Birthday" color="name"
date_start="dob"
quick_add="False" avatar_model="hr.employee">
<field name="name"/>
</calendar>
</field>
</record>
<record model="ir.actions.act_window" id="action_birthday_view">
<field name="name">Birthday</field>
<field name="res_model">birthday.report</field>
<field name="view_type">form</field>
<field name="view_mode">calendar</field>
<field name="view_id" eval="view_birthday_report_calendar"/>
<field name="domain">[]</field>
</record>
<menuitem id="menu_birthday" name="Birthday" parent="hr.menu_hr_root" groups="base.group_user"/>
<menuitem id="menu_view_birthday" parent="menu_birthday" action="action_birthday_view" groups="base.group_user"/>
</data>
</openerp>
Error shows up when I navigate to January or previous year December, the following error occurs :
Uncaught Error: '2016-' is not a correct date, datetime nor time.
I am new to sql queries in Odoo, Anyone with suggestions on this would be really grateful. Thanks !!
First, I recommend using || instead of concat. That allows you to do multiple concatenations.
date_part('Year',current_date) || '-' || to_char(h.birthday, 'mm-dd')
Secondly I recommend casting to date, so
(date_part('Year',current_date) || '-' || to_char(h.birthday, 'mm-dd'))::date
Third, what happens if you just use psql and select from the view? Are there malformed dates? Or is something else happening elsewhere in your Python code?

BlazeDS Messaging Channel.Connect.Failed Error

I searched through the internet and any answer for this error could not solved my problem.
I have a blazeds server in Openshift and I'm connecting to it via Flash Builder.
I want to make an app that will send a message to all other users who are using my app.
I mean I have 2 applications. One will send a message to server and this one will be on Desktop, the other one is a mobile project and will receive messages that I sent from desktop app through server.
I tried to use BlazeDS messaging but it's giving me this error:
(mx.messaging.messages::ErrorMessage)#0
body = (Object)#1
clientId = (null)
correlationId = "96461BC6-7288-A95C-923B-B32FCDDC9CE3"
destination = ""
extendedData = (null)
faultCode = "Client.Error.MessageSend"
faultDetail = "Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://ainApp.swf/messagebroker/amfpolling'"
faultString = "Send failed"
headers = (Object)#2
messageId = "147C1B6F-6877-79D8-3BCA-B32FCDF5E3F9"
rootCause = (mx.messaging.events::ChannelFaultEvent)#3
bubbles = false
cancelable = false
channel = (mx.messaging.channels::AMFChannel)#4
authenticated = false
channelSets = (Array)#5
connected = false
connectTimeout = -1
enableSmallMessages = true
endpoint = "http://ainApp.swf/messagebroker/amfpolling"
failoverURIs = (Array)#6
id = "my-polling-amf"
mpiEnabled = false
netConnection = (flash.net::NetConnection)#7
client = (mx.messaging.channels::AMFChannel)#4
connected = false
httpIdleTimeout = 0
maxPeerConnections = 8
objectEncoding = 3
proxyType = "none"
uri = "http://ainApp.swf/messagebroker/amfpolling"
piggybackingEnabled = false
polling = false
pollingEnabled = true
pollingInterval = 4000
protocol = "http"
reconnecting = false
recordMessageSizes = false
recordMessageTimes = false
requestTimeout = -1
uri = "http://{server.name}:{server.port}/messagebroker/amfpolling"
url = "http://{server.name}:{server.port}/messagebroker/amfpolling"
useSmallMessages = false
channelId = "my-polling-amf"
connected = false
currentTarget = (mx.messaging.channels::AMFChannel)#4
eventPhase = 2
faultCode = "Channel.Connect.Failed"
faultDetail = "NetConnection.Call.Failed: HTTP: Failed: url: 'http://ainApp.swf/messagebroker/amfpolling'"
faultString = "error"
reconnecting = false
rejected = false
rootCause = (Object)#8
code = "NetConnection.Call.Failed"
description = "HTTP: Failed"
details = "http://ainApp.swf/messagebroker/amfpolling"
level = "error"
target = (mx.messaging.channels::AMFChannel)#4
type = "channelFault"
timestamp = 0
timeToLive = 0
This is my desktop application that I'm trying to send messages from:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.messaging.events.ChannelEvent;
import mx.messaging.events.MessageFaultEvent;
import mx.messaging.messages.AsyncMessage;
protected function cons_faultHandler(event:MessageFaultEvent):void
{
trace(event.message + ' fault')
}
]]>
</fx:Script>
<fx:Declarations>
<s:Consumer id="cons" destination="cricket" message="messages.text += event.message.body.msg + '\n'" fault="cons_faultHandler(event)"/>
<s:Producer id="prod" destination="cricket" fault="cons_faultHandler(event)" />
</fx:Declarations>
<s:VGroup verticalScrollPosition="0" horizontalScrollPosition="0">
<s:TextArea id="messages" width="100%" height="50%"/>
<s:TextInput id="mesgSender" />
<s:Button id="send" label="send" click="prod.send(new AsyncMessage({msg:mesgSender.text+'asdasd'}))"/>
</s:VGroup>
</s:WindowedApplication>
And this are my messaging-config.xml and services-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<service-include file-path="remoting-config.xml" />
</services>
<security>
<login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/>
</security>
<channels>
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
</channels>
<logging>
<target class="flex.messaging.log.ConsoleTarget" level="Error">
<properties>
<prefix>[BlazeDS] </prefix>
<includeDate>false</includeDate>
<includeTime>false</includeTime>
<includeLevel>false</includeLevel>
<includeCategory>false</includeCategory>
</properties>
<filters>
<pattern>Endpoint.*</pattern>
<pattern>Service.*</pattern>
<pattern>Configuration</pattern>
</filters>
</target>
</logging>
<system>
<redeploy>
<enabled>false</enabled>
</redeploy>
</system>
</services-config>
<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service"
class="flex.messaging.services.MessageService">
<adapters>
<adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />
<!-- <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/> -->
</adapters>
<default-channels>
<channel ref="my-polling-amf"/>
</default-channels>
<destination id="cricket">
<channel ref="my-amf"/>
</destination>
</service>
I don't know what I'm doing wrong and why in error message, the endpoint url is "http://ainApp.swf/messagebroker/amfpolling". My desktop apps name is MainApp by the way.
Thanks
In services-config.xml you should define your channel url.
url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"
to like this
url="/yourContextRootName/messagebroker/amf"
Do not define server.name and server.port, it comes with similar problem.

.net to coldfusion web service xml parsing

I'm almost there with this project. Given the xml below:
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<debtor xmlns="http://tempuri.org/Database.xsd">
<Customer diffgr:id="Customer1" msdata:rowOrder="0" diffgr:hasErrors="true">
<SeqNo>-1</SeqNo>
<AccGroup>1</AccGroup>
<AccountTypeID>1</AccountTypeID>
<CompaniesOfficeID>-4</CompaniesOfficeID>
<DOB />
<SignupDate>18/04/2007</SignupDate>
<DeferredDate />
<TeleSalesNo>5</TeleSalesNo>
<PIN>4433</PIN>
<Name>MR DAVID GETTI</Name>
<Salutation>MR</Salutation>
<FirstName>DAVID</FirstName>
<LastName>GETTI</LastName>
<Phone>64 7 555 522</Phone>
<Fax />
<CellPhone>64 25 999 999</CellPhone>
<Email>dave.getti#cpass.net.nz</Email>
<AfterHrs_Contact />
<SalesNo>0</SalesNo>
<CreditStatus>1</CreditStatus>
<RefGroupNo>0</RefGroupNo>
<PriceNo>-1</PriceNo>
<SmartLineProvider>-1</SmartLineProvider>
<Contact>DAVID GETTI</Contact>
<CustomerCode>1111111</CustomerCode>
<HasCellPhone>false</HasCellPhone>
<InvoiceOptions>12</InvoiceOptions>
<TradingAs>MR DAVID GETTI</TradingAs>
<FranchiseCode>-1</FranchiseCode>
<Existing>true</Existing>
<Address diffgr:id="Address1" msdata:rowOrder="0">
<SeqNo>-1</SeqNo>
<CustomerSeqNo>-1</CustomerSeqNo>
<Show>30</Show>
<TypeSelected>2</TypeSelected>
<Name>PostalAddress</Name>
<AddressNumber />
<Address1>88 Blue Lane East</Address1>
<Address2>REMA</Address2>
<Address3>AKL</Address3>
<Address4 />
<PostCode>1050</PostCode>
<LocationCode>0</LocationCode>
<AgentID>0</AgentID>
</Address>
<Address diffgr:id="Address2" msdata:rowOrder="1">
<SeqNo>-2</SeqNo>
<CustomerSeqNo>-1</CustomerSeqNo>
<Show>10</Show>
<TypeSelected>2</TypeSelected>
<Name>PhysicalAddress</Name>
<AddressNumber />
<Address1>44 OHINA STREET</Address1>
<Address2>REMA</Address2>
<Address3>AKL</Address3>
<Address4 />
<PostCode>1098</PostCode>
<LocationCode>1</LocationCode>
<AgentID>1</AgentID>
</Address>
I can access all the data, except the address details and populate a query object, using the code below:
<cfset Local.xRows = Local.xData["diffgr:diffgram"]["debtor"] />
<cfloop from="1" to="#arrayLen(Local.xRows.xmlChildren)#" index="Local.i">
<cfset Local.thisRow = Local.xRows.xmlChildren[Local.i] />
<cfset Local.tableName = Local.thisRow.xmlName />
<cfset queryAddRow(Local.result[Local.tableName], 1) />
<cfloop from="1" to="#arrayLen(Local.thisRow.xmlChildren)#" index="Local.j">
<cfif listfindnocase(vCols,Local.thisRow.xmlChildren[Local.j].xmlName)>
<cfset querySetCell(Local.result[Local.tableName], Local.thisRow.xmlChildren[Local.j].xmlName, Local.thisRow.xmlChildren[Local.j].xmlText, Local.result[Local.tableName].recordCount) />
</cfif>
</cfloop>
</cfloop>
However, I am stuck with how to access the individual address detail nodes under the main address node:
<Address diffgr:id="Address1" msdata:rowOrder="0">
Any help would be greatly appreciated.
I think you're trying to reference those individual nodes using an absolute reference instead of the easier local reference you get by using cfloop.
<cfset xmlCustomerInfo = xmlDoc.info[ "Customer" ][ Local.i ] />
<cfset arrAddressList = xmlCustomerInfo[ "Address" ] />
<cfloop
index="Local.j"
from="1"
to="#ArrayLen( arrAddressList )#"
step="1">
<cfset innerAddressNode = arrAddressList[ Local.j ] />
</cfloop>
Here are some great references to parsing XML in Coldfusion.
WARNING: Code is un-tested, just based on what you presented and how coldfusion parses Xml documents.

Resources