我使用CFHTTP实现了大多数API调用一切正常。 我使用下面的代码来创建谷歌日历活动。 传递给它的每个参数都是正确的(有效的)。但是使用cfhttp它没有被发送。 我收到了Filecontent错误
{ "error":
{ "errors": [
{ "domain": "global",
"reason": "required",
"message": "Missing end time."
} ],
"code": 400, "message": "Missing end time."
}
}
代码
<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>