CFArgument 导致函数 return 错误 415
CFArgument is causing the function to return ERROR 415
我正在尝试在 CF11 中创建 REST Web 服务,但我收到一个错误,我不太明白它的来源。
步骤 1
我创建了一个函数,它 returns 查询结果 - 工作正常
第 2 步
添加了几个 CFArguments
和函数 returns 415 Unsupported Media Type
第 3 步
删除了 cfarguments,该函数再次运行.....
有人有推荐吗?
这是组件
<cfcomponent restpath="student" rest="true">
<cffunction name="dbTest" access="remote" output="false" returntype="query" httpmethod="get" restpath="dbTest">
<cfargument name="addSFSurveys" type="numeric" required="No" default="0">
<cfargument name="showRatings" type="numeric" required="No" default="5">
<cfargument name="siteID" type="numeric" required="No" default="0">
<cfargument name="pageID" type="numeric" required="No" default="0">
<cfargument name="includeDoctor" type="numeric" required="No" default="1">
<cfargument name="topReviews" type="string" required="No" default="">
<cfargument name="testimonialID" type="string" required="No" default="">
<cfargument name="procedureID" type="string" required="No" default="">
<cfargument name="detailedScore" type="string" required="No" default="">
<cfargument name="minScore" type="string" required="No" default="">
<cfargument name="maxScore" type="string" required="No" default="">
<cfquery name="testimonials" datasource="dpsigweb2">
select distinct top 10 cast(t.testimonial as varchar(max)) as testimonial, t.contactid, t.doctorid,
c.first as first, left(c.last,1) as last, c.city, c.state, d.practiceNameDisplay, t.featured, t.owneridfk , cd.city as docCity, cd.state as docState, cd.zip as docZip,
'' as sorter, t.testimonialID , cast(t.title as varchar(max)) as title ,cast(st.finalscore as decimal(10,1)) as finalscore, CAST(se.procedureID AS varchar(25)) COLLATE Latin1_General_BIN as procedureID,
st.dateComplete as surveyDate, se.revenue as cost, se.locationName, consultloc = (select top 1 se2.locationname from survey.dbo.survey_events se2 join survey.dbo.surveys s on se2.surveytypeidfk = s.id
where c.contactid = se2.contactidfk and se2.locationname is not null and isnull(s.surveytypecatidfk,0) <> 1 order by se.eventdate desc)
from testimonials t
join contact c on t.contactid = c.contactid
join doctor d on t.doctorid = d.doctorID
join contact cd on cd.contactID = d.contactID
left join testimonial_sites ts on ts.testimonialID = t.TestimonialID
left join survey_tracking st on st.owneridfk= t.owneridfk
left join survey.dbo.survey_events se on se.id= st.surveyEventID
where t.owneridfk != ''
and ts.siteID= '9'
order by surveyDate desc
</cfquery>
<cfreturn testimonials>
</cffunction>
</cfcomponent>
结果
您应该在 <cfargument>
中添加一个 restArgSource
以便它可以找出从哪里获取变量
见https://wikidocs.adobe.com/wiki/display/coldfusionen/cfargument
希望能给你一点指导
我正在尝试在 CF11 中创建 REST Web 服务,但我收到一个错误,我不太明白它的来源。
步骤 1
我创建了一个函数,它 returns 查询结果 - 工作正常
第 2 步
添加了几个 CFArguments
和函数 returns 415 Unsupported Media Type
第 3 步
删除了 cfarguments,该函数再次运行.....
有人有推荐吗?
这是组件
<cfcomponent restpath="student" rest="true">
<cffunction name="dbTest" access="remote" output="false" returntype="query" httpmethod="get" restpath="dbTest">
<cfargument name="addSFSurveys" type="numeric" required="No" default="0">
<cfargument name="showRatings" type="numeric" required="No" default="5">
<cfargument name="siteID" type="numeric" required="No" default="0">
<cfargument name="pageID" type="numeric" required="No" default="0">
<cfargument name="includeDoctor" type="numeric" required="No" default="1">
<cfargument name="topReviews" type="string" required="No" default="">
<cfargument name="testimonialID" type="string" required="No" default="">
<cfargument name="procedureID" type="string" required="No" default="">
<cfargument name="detailedScore" type="string" required="No" default="">
<cfargument name="minScore" type="string" required="No" default="">
<cfargument name="maxScore" type="string" required="No" default="">
<cfquery name="testimonials" datasource="dpsigweb2">
select distinct top 10 cast(t.testimonial as varchar(max)) as testimonial, t.contactid, t.doctorid,
c.first as first, left(c.last,1) as last, c.city, c.state, d.practiceNameDisplay, t.featured, t.owneridfk , cd.city as docCity, cd.state as docState, cd.zip as docZip,
'' as sorter, t.testimonialID , cast(t.title as varchar(max)) as title ,cast(st.finalscore as decimal(10,1)) as finalscore, CAST(se.procedureID AS varchar(25)) COLLATE Latin1_General_BIN as procedureID,
st.dateComplete as surveyDate, se.revenue as cost, se.locationName, consultloc = (select top 1 se2.locationname from survey.dbo.survey_events se2 join survey.dbo.surveys s on se2.surveytypeidfk = s.id
where c.contactid = se2.contactidfk and se2.locationname is not null and isnull(s.surveytypecatidfk,0) <> 1 order by se.eventdate desc)
from testimonials t
join contact c on t.contactid = c.contactid
join doctor d on t.doctorid = d.doctorID
join contact cd on cd.contactID = d.contactID
left join testimonial_sites ts on ts.testimonialID = t.TestimonialID
left join survey_tracking st on st.owneridfk= t.owneridfk
left join survey.dbo.survey_events se on se.id= st.surveyEventID
where t.owneridfk != ''
and ts.siteID= '9'
order by surveyDate desc
</cfquery>
<cfreturn testimonials>
</cffunction>
</cfcomponent>
结果
您应该在 <cfargument>
中添加一个 restArgSource
以便它可以找出从哪里获取变量
见https://wikidocs.adobe.com/wiki/display/coldfusionen/cfargument
希望能给你一点指导