1 Replies - 330 Views - Last Post: 15 January 2019 - 10:50 AM Rate Topic: -----

#1 chrisdonkor   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-June 11

CFHTTP Connection Challenge

Posted 15 January 2019 - 07:01 AM

I am trying to connect to an api using the following code:

<cfhttp method="Post" url="https://sandbox.expresspaygh.com/api/submit.php">
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" />
<cfhttpparam type="Formfield" name="merchant-id" value="zzzz">
<cfhttpparam type="Formfield" name="api_key" value="xxxx">
<cfhttpparam type="Formfield" name="firstname" value="Chris">
<cfhttpparam type="Formfield" name="lastname" value="Donkor">
<cfhttpparam type="Formfield" name="email" value="[email protected]">
<cfhttpparam type="Formfield" name="phonenumber" value="0242511110">
<cfhttpparam type="Formfield" name="currency" value="GHC">
<cfhttpparam type="Formfield" name="amount" value="1000">
<cfhttpparam type="Formfield" name="order-id" value="001">
<cfhttpparam type="Formfield" name="order-desc" value="Test">
<cfhttpparam type="Formfield" name="redirect-url" value="https://www.chrisdonkor.org">
<cfhttpparam type="Formfield" name="post-url" value="https://www.chrisdonkor.org">
</cfhttp>

					<cfoutput>
						File Content:<br>
						#cfhttp.filecontent#<br>
						Mime Type:#cfhttp.MimeType#<br>
					</cfoutput>



I keep getting the following results:

File Content:
Connection Failure
Mime Type:Unable to determine MIME type of file.

You help will be greatly appreciated

Mod edit - please :code:/>

This post has been edited by Craig328: 15 January 2019 - 10:42 AM
Reason for edit:: Remove merchant ID and API key


Is This A Good Question/Topic? 0
  • +

Replies To: CFHTTP Connection Challenge

#2 Craig328   User is offline

  • I make this look good
  • member icon

Reputation: 2042
  • View blog
  • Posts: 3,644
  • Joined: 13-January 08

Re: CFHTTP Connection Challenge

Posted 15 January 2019 - 10:50 AM

Welcome to DIC chrisdonkor! The issue you're encountering is pretty standard for setting up web services connections. In this case, you're trying to submit form information to a remote data receiver and the process is failing. The error message does tell you, pretty much, exactly what the problem is: "Unable to determine MIME type of file".

You need to tell the receiving authority just what it is you're sending them. In order to do that, you need to add a second cfhttpparam tag to your effort here. That second tag will be used to pass the receiving end the mime type of the content you're sending it. An example, for instance, might look something like this:
<cfhttpparam type="header" name="mimetype" value="application/xml" />


Anyway, have a look at the link for the tag (above) and that should start you in the right direction. Good luck!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1