I'm trying to post an image to an album via the Facebook Graph API with following ColdFusion-Code:
<cfhttp method="post" url="https://graph.facebook.com/#albumid#/photos/">
<cfhttpparam type="formfield" name="access_token" value="#access_token#" />
<cfhttpparam type="file" name="source" file="#img_dir#\dummy.jpg" />
<cfhttpparam type="formfield" name="message" value="foo bar" />
<cfhttpparam type="formfield" name="no_story" value="true" />
</cfhttp>
If I omit no_story=true, the whole thing works perfectly, however I need this attribute to prevent the post from appearing on my wall. I'm getting this error:
{"error":{"message":"(#100) Param no_story must be a boolean","type":"OAuthException","code":100}}
HTTP/1.1 400 Bad Request Content-Type: text/javascript; charset=UTF-8 WWW-Authenticate: OAuth "Facebook Platform" "invalid_request" "(#100) Param no_story must be a boolean" Access-Control-Allow-Origin: * X-FB-Rev: 1568945 Pragma: no-cache Cache-Control: no-store Facebook-API-Version: v2.2 Expires: Sat, 01 Jan 2000 00:00:00 GMT X-FB-Debug: Vt7Viz/nlNfsQDDfNKtVuBjfgjDiWPFxYb0TAEpJJa9NjrR+TrEB8nuMOerQJYMX9E2e1CeqfBZT70/1KODErg== Date: Wed, 21 Jan 2015 12:13:31 GMT Connection: close Content-Length: 98
I have tried following variations:
<cfhttpparam type="formfield" name="no_story" value="TRUE" />
<cfhttpparam type="formfield" name="no_story" value="True" />
<cfhttpparam type="formfield" name="no_story" value="#true#" />
<cfhttpparam type="formfield" name="no_story" value="#JavaCast('boolean', true)#" />
<cfhttpparam type="formfield" name="no_story" value="1" />
<cfhttpparam type="formfield" name="no_story" value="Yes" />
None of these worked.
Difficult to test that out, but I suspect maybe it is passing the text as opposed to the boolean value. Maybe try:
<cfset mytruebool = True>
Then:
<cfhttpparam type="formfield" name="no_story" value="#mytruebool#" />
The key difference being no quotes on the cfset assignment.
Related
There's this web service I want to connect to. It's fully detailed here: https://simphonytsapi.docs.apiary.io/#reference/calculatetransactiontotals/overview/example-1?console=1
As you can see there's details on the right on how to connect to it. For example to call the CalculateTransactionTotals method of the web service there is:
This .asmx URL: https://private-102dc-simphonytsapi.apiary-mock.com/1/EGateway/SimphonyPosApiWeb.asmx
And these headers:
Content-Type text/xml;charset=UTF-8
SOAPAction http://micros-hosting.com/EGateway/CalculateTransactionTotals
And this example request body:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<CalculateTransactionTotals xmlns="http://micros-hosting.com/EGateway/">
<vendorCode />
<ppMenuItems />
<ppComboMeals>
<SimphonyPosApi_ComboMeal>
<ComboMealMainItem>
<Condiments />
<MenuItem>
<ItemDiscount>
<DiscObjectNum>0</DiscObjectNum>
</ItemDiscount>
<MiObjectNum>181020001</MiObjectNum>
<MiReference />
<MiWeight />
<MiMenuLevel>1</MiMenuLevel>
<MiSubLevel>1</MiSubLevel>
<MiPriveLevel>0</MiPriveLevel>
</MenuItem>
</ComboMealMainItem>
<ComboMealMenuItem>
<Condiments />
<MenuItem>
<ItemDiscount>
<DiscObjectNum>0</DiscObjectNum>
</ItemDiscount>
<MiObjectNum>181010001</MiObjectNum>
<MiReference />
<MiWeight />
<MiMenuLevel>1</MiMenuLevel>
<MiSubLevel>1</MiSubLevel>
<MiPriveLevel>0</MiPriveLevel>
</MenuItem>
</ComboMealMenuItem>
<ComboMealObjectNum>11</ComboMealObjectNum>
<SideItems>
<SimphonyPosApi_MenuItem>
<Condiments />
<MenuItem>
<ItemDiscount>
<DiscObjectNum>0</DiscObjectNum>
</ItemDiscount>
<MiObjectNum>181030001</MiObjectNum>
<MiReference />
<MiWeight />
<MiMenuLevel>1</MiMenuLevel>
<MiSubLevel>1</MiSubLevel>
<MiPriveLevel>0</MiPriveLevel>
</MenuItem>
</SimphonyPosApi_MenuItem>
<SimphonyPosApi_MenuItem>
<Condiments />
<MenuItem>
<ItemDiscount>
<DiscObjectNum>0</DiscObjectNum>
</ItemDiscount>
<MiObjectNum>299030001</MiObjectNum>
<MiReference />
<MiWeight />
<MiMenuLevel>1</MiMenuLevel>
<MiSubLevel>1</MiSubLevel>
<MiPriveLevel>0</MiPriveLevel>
</MenuItem>
</SimphonyPosApi_MenuItem>
</SideItems>
</SimphonyPosApi_ComboMeal>
</ppComboMeals>
<pSvcCharge>
<SvcChgObjectNum>0</SvcChgObjectNum>
</pSvcCharge>
<pSubtotalDiscount>
<DiscObjectNum>0</DiscObjectNum>
</pSubtotalDiscount>
<revenueCenter>11</revenueCenter>
<orderType>1</orderType>
<employeeNumber>900000092</employeeNumber>
<pTotalsResponse />
</CalculateTransactionTotals>
</soap:Body>
</soap:Envelope>
I need the WSDL to connect to this web service. How do I get it?
I am trying to get 3 options condition, but I am going crazy:
In a specific field may appear a number, a text or be an empty field
Conditions:
if any text = warning message pops up: "This in an error "
if any number= [pagedown] action
if empty = warning message pops up: "pls change code "
May someone help me?
Thanks!
<HAScript name="new condition" description="" timeout="60000" pausetime="300" promptall="te" blockinput="false" author="gennaro" creationdate="Nov 19, 2022 8:07:14 PM" supressclearevents="false" usevars="true" ignorepauseforenhancedtn="true" delayifnotenhancedtn="0" ignorepausetimeforenhancedtn="true">
<vars>
<create name="$text$" type="string" value="" />
<create name="$num$" type="integer" value="0" />
<create name="$emptyfield$" type="field" />
</vars>
<screen name="Screen1" entryscreen="true" exitscreen="true" transient="false">
<description >
<oia status="NOTINHIBITED" optional="false" invertmatch="false" />
</description>
<actions>
<extract name="'Extract'" planetype="TEXT_PLANE" srow="6" scol="66" erow="6" ecol="70" unwrap="false" continuous="false" assigntovar="$text$" />
<extract name="'Extract'" planetype="TEXT_PLANE" srow="6" scol="66" erow="6" ecol="70" unwrap="false" continuous="false" assigntovar="$num$" />
<extract name="'Extract'" planetype="TEXT_PLANE" srow="6" scol="66" erow="6" ecol="70" unwrap="false" continuous="false" assigntovar="$emptyfield$" />
<if condition="$string$" >
<input value="" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
<message title="$string$" value="" />
</if>
<if condition="$num$" >
<input value="'[pagedn]'" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
</if>
<if condition="$emptyfield$" >
<message title="$emptyfield$" value="" />
</if>
</actions>
<nextscreens timeout="0" >
</nextscreens>
</screen>
</HAScript>
I was expecting
Conditions:
if any text = warning message pops up: "This in an error "
if any mumber= [pagedoen] action
if empty = warning message pops up: "pls change code "
I am working with a SOAP request in coldfusion. When the code I have is run from a .CFM file, it works. If it is run from a .CFC file, it doesn't work. The code is the same as far as possible (the .CFC needs the cfcomponent and cffunction tags for example).
Why would it work from one and not the other? When I call it from the CFC page I get the error
Does anyone have any idea why this might be happening? The SOAP request is identical on both pages. The call with the CFHTTP as well as all the CFHTTPPARAMs are the same as well.
Here is the code for the CFC file:
<cfcomponent>
<cffunction name="updateAgParcel" returntype="string" returnformat="plain" access="remote">
<cfargument name="ag_pres_nr" required="true" type="string">
<cfargument name="emp_nr" required="true" type="string">
<cfargument name="dt_rcvd" required="true" type="string">
<cfset dt_rcvd = DateFormat(#dt_rcvd#,"MMDDYYYY")>
<cfsavecontent variable="soapBody">
<cfoutput>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ass="http://XXXXXX">
<soapenv:Header/>
<soapenv:Body>
<ass:LogAgPreserveFiling>
<ass:AG.PRES.NR>#ag_pres_nr#</ass:AG.PRES.NR>
<ass:TC>04</ass:TC>
<ass:EMP.NR>#emp_nr#</ass:EMP.NR>
<ass:LCAQ.DT.RCVD>#dt_rcvd#</ass:LCAQ.DT.RCVD>
</ass:LogAgPreserveFiling>
</soapenv:Body>
</soapenv:Envelope>
</cfoutput>
</cfsavecontent>
<cfhttp url="XXXXXXXXXXXXXXX" method="post" result="httpResponse">
<cfhttpparam type="header" name="SOAPAction" value="XXXXXXXXXXXX" />
<cfhttpparam type="header" name="Authorization" value="Basic XXXXXXXXXXXXXX" />
<cfhttpparam type="header" name="accept-encoding" value="no-compression" />
<cfhttpparam type="header" name="Content-Type" value="text/xml" />
<cfhttpparam type="xml" value="#trim( soapBody )#" />
</cfhttp>
<cfif find( "200", httpResponse.statusCode )>
<cfset soapResponse = xmlParse( httpResponse.fileContent ) />
<cfset responseNodes = xmlSearch(soapResponse, "//*[ local-name() = 'VCfaultdetails'] ") />
<cfif arrayLen(responseNodes) NEQ 0>
<cfset error = #responseNodes[ 1 ].message.xmlText#>
<cfreturn error>
<cfelse>
<cfreturn "">
</cfif>
</cfif>
</cffunction>
</cfcomponent>
Code for the CFM version:
<cfsavecontent variable="soapBody">
<cfoutput>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ass="http://XXXXX">
<soapenv:Header/>
<soapenv:Body>
<ass:LogAgPreserveFiling>
<ass:AG.PRES.NR>#ag_pres_nr#</ass:AG.PRES.NR>
<ass:TC>04</ass:TC>
<ass:EMP.NR>#emp_nr#</ass:EMP.NR>
<ass:LCAQ.DT.RCVD>#dt_rcvd#</ass:LCAQ.DT.RCVD>
</ass:LogAgPreserveFiling>
</soapenv:Body>
</soapenv:Envelope>
</cfoutput>
</cfsavecontent>
<cfhttp url="XXXXXXXXXXXXX" method="post" result="httpResponse">
<cfhttpparam type="header" name="SOAPAction" value="XXXXXXXXXXXXXXX"/>
<cfhttpparam type="header" name="content-type" value="text/xml">
<cfhttpparam type="header" name="Authorization" value="Basic XXXXXXXXXXXXXXXXX" />
<cfhttpparam type="header" name="accept-encoding" value="no-compression" />
<cfhttpparam type="xml" value="#trim( soapBody )#" />
</cfhttp>
<cfif find( "200", httpResponse.statusCode )>
<cfset soapResponse = xmlParse( httpResponse.fileContent ) />
<cfset responseNodes = xmlSearch( soapResponse, "//*[ local-name() = 'VCfaultdetails'] " ) />
<cfif arrayLen(responseNodes) NEQ 0>
<cfoutput>
Code: #responseNodes[ 1 ].errorcode#
<br />
Message: #responseNodes[ 1 ].message#
</cfoutput>
<cfelse>
Success!!!!!!!!
</cfif>
</cfif>
I XXXXXX out some of the URL's and such for security. Also, sorry for the namespace the developers choose (ass:). It was the abbreviation for Assessor. Somebody was being funny...
I create a REST service in CF11 and up until last night everything was working fine until I started getting CORS errors all over the place.
Long story short this is my code:
<cfcomponent rest="true" restPath="/testimonials">
<cffunction name="getTestimonials" access="remote" returntype="any" httpMethod="GET" restPath="/getTestimonials">
<cfargument name="showRatings" type="numeric" restArgSource="Query" default="0">
<cfargument name="siteID" type="numeric" restArgSource="Query" default="0">
<cfargument name="pageID" type="numeric" restArgSource="Query" default="0">
.....
And I am calling it like this
<cfhttp url="http://dev.example.com/rest/api/testimonials/getTestimonials" method="GET" result="res">
<cfhttpparam type="URL" name="showRatings" value="0">
<cfhttpparam type="URL" name="siteID" value="17">
<cfhttpparam type="URL" name="pageID" value="2">
</cfhttp>
<cfdump var="#res#">
And this is the return struct that I am getting back
struct
Charset [empty string]
ErrorDetail [empty string]
Filecontent [empty string]
Header HTTP/1.1 200 OK Access-Control-Allow-Methods: POST,GET,OPTIONS Date: Wed, 23 Sep 2015 08:14:02 GMT Content-Length: 0 Access-Control-Allow-Headers: Content-Type Access-Control-Allow-Origin: * Server: Microsoft-IIS/8.0 X-Powered-By: ASP.NET server-error: true
Mimetype Unable to determine MIME type of file.
Responseheader
struct
Access-Control-Allow-Headers Content-Type
Access-Control-Allow-Methods POST,GET,OPTIONS
Access-Control-Allow-Origin *
Content-Length 0
Date Wed, 23 Sep 2015 08:14:02 GMT
Explanation OK
Http_Version HTTP/1.1
Server Microsoft-IIS/8.0
Status_Code 200
X-Powered-By ASP.NET
server-error true
Statuscode 200 OK
Text YES
Nothing Changed as far as I know code-wise or on my IIS server to justify this error. I even added the code below in my web.config to try and enable CORS
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*"/>
<add name="Access-Control-Allow-Headers" value="Content-Type"/>
<add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS"/>
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
Today while working with ColdFusion 10 REST, I got an issues. I am not sure how to pass data to a REST service in FORM scope.
Here is my REST enabled CFC,
<cfcomponent rest="true" restpath="/crudService" >
<cfset variable.myQuery = queryNew("Id,Name","Integer,Varchar",[[1,"Test1"],[2,"Test2"],[3,"Test3"]] )>
<cffunction name="getHandlerJSONForm" access="remote" httpmethod="GET" restpath="/formtest" returntype="query" produces="application/xml">
<cfargument name="customerID" required="true" restargsource="Form" type="numeric" >
<cfquery dbtype="query" name="local.qryGetUserName">
SELECT Name
FROM variable.myQuery
WHERE Id = <cfqueryparam cfsqltype="cf_sql_integer" value="#customerID#">
</cfquery>
<cfreturn local.qryGetUserName>
</cffunction>
</cfcomponent>
Here is the CFM code, calling the REST service,
<cfset restInitApplication("E:\Local Workspace\cfcs\rest","myfirstrest")>
<cfhttp url="http://cflocal.com/rest/myfirstrest/crudService/formtest" method="get" >
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" >
<cfhttpparam type="formfield" name="customerID" value="1" >
</cfhttp>
<cfdump var="#cfhttp#">
In StatusCode I am getting 500 Exception obtaining parameters ?
Please suggest whats going wrong here.