Forum Discussion
Sorry to hijack this thread but I am receiving the error below and the link posted below is now broken.
{ "Errors": [ { "Name": "FileExtensionRequired", "Message": "Original file type must be .pdf .tiff .jpg .jpeg .x-ms-png or .png and must be consistent in decoded file base64 content", "AdditionalDetails": "", "ErrorCode": 80000, "Severity": "Error", "LearnMore": null } ], "Information": "Warning, error messages have not been finalised in this release and may change" }
My Code Snippet
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>'{
"Attachment":
{
"OriginalFileName": "{{test.jpg}}",
"FileBase64Content": "{{.$postdata.}}"
}
}',
CURLOPT_HTTPHEADER => $this->header,
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;thank you for any help..
Ben
Hi Ben,
I just noticed my synatx may be a bit misleading in the sample i showed. I wrapped the fields with {{ & }} as they appear as a placeholder in the MYOB dev documentation.
However, the actual syntax should be:
{
"Attachment":
{
"OriginalFileName": "test.jpg",
"FileBase64Content": "base64.encoded_file_string"
}
}I'm by no means a CURL programmer, but the above is the syntax i use with no issues.
Hope this helps.
- Viital5 years agoContributing User
Thanks Dean. I really appreciated.
I have managed to get the upload working perfectly.
Looking for something else?
Search the Community Forum for answers or find your topic and get the conversation started!
Find technical support and help for all MYOB products in our online help centre
Dig into MYOB Academy for free courses, learning paths and live events to help build your business with MYOB.