On a website I build we're using Wufoo forms to centralize data. So I have a trivial form that I have to submit to Wufoo, using their rest API.
I did everything according to their documentation, but I still get an error when sending the POST request to their endpoint.
This is how my request looks like:
$ref = curl_init('https://{domain}.wufoo.com/api/v3/forms/' . WUFOO_FORM_HASH . '/entries.json');
curl_setopt($ref, CURLOPT_HTTPHEADER, array('Content-type: multipart/form-data'));
curl_setopt($ref, CURLOPT_POST, true);
curl_setopt($ref, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ref, CURLOPT_POSTFIELDS, $_formData);
curl_setopt($ref, CURLOPT_USERPWD, WUFOO_API_KEY . ':X');
curl_setopt($ref, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ref, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ref, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($ref, CURLOPT_FOLLOWLOCATION, true);
$result = json_decode(curl_exec($ref), true);
And this is the $_formData array:
Array
(
[Field4] => firstname
[Field3] => lastname
[Field5] => [email protected]
[Field110] => @/var/tmp/random_name/test.txt
)
Whenever I attach a file to the request in Field110, the request fails with this as an error:
Array
(
[Success] => 0
[ErrorText] => Errors have been <b>highlighted</b> below.
[FieldErrors] => Array
(
[0] => Array
(
[ID] => Field110
[ErrorText] => This file was NOT successfully uploaded. Please try again.
)
)
)
Anyone got this problem before and know any solutions? I have to mention that I MUST use the Wufoo rest API to submit this.
According to the error message the file was not properly successfully uploaded. Meaning there is an issue either with the path, size or type of the file.
Max size for a file is 10MB and for all the fields in a single form is 20MB combined.
Why dont you use the Wufoo API PHP Wrapper it allows among other things to post entries with files....