Attaching PDF to bill API

This thread is now closed to new comments.
Some of the links and information provided in this thread may no longer be available or relevant.
If you have a question please start a new post.
Viital
Contributing User
5 Posts
Contributing User
Contributing User

5Posts

0Kudos

0Solutions

Attaching PDF to bill API

Hi I have had the below working for several months but about a week ago this stopped working. Did the API receive an update?

 

{
  "Errors": [
    {
      "Name": "InternalError",
      "Message": "An exception was thrown that was not handled correctly. If this situation persists please contact developers@myob.com for further assistance.",
      "AdditionalDetails": null,
      "ErrorCode": 20,
      "Severity": "Error",
      "LearnMore": null
    }
  ],
  "Information": "Warning, error messages have not been finalised in this release and may change"
}

 

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://ar2.api.myob.com/accountright/cf....fd/Purchase/Bill/Service/bf7....68/Attachment',
  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": "me.pdf",

"FileBase64Content": "JVBER.....=="

}

}',
  CURLOPT_HTTPHEADER => array(
    'x-myobapi-key: secretkey',
    'x-myobapi-version: v2',
    'Accept-Encoding: gzip,deflate',
    'Content-Type: application/json',
    'Authorization: Bearer AAE.......uw'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
2 REPLIES 2
Hannah_B
MYOB Moderator
142 Posts
MYOB Moderator
Australia
MYOB Moderator

142Posts

33Kudos

25Solutions

Re: Attaching PDF to bill API

Hi @Viital

 

Thank you for reaching out, Please ensure that you are POSTing the correct body request with all of the required fields. You can view our support note HERE which has examples of the mandatory fields for the Bills Attachment endpoint.


Thanks,
@Hannah_B


MYOB API Specialist


MYOB API Support Centre|MYOB App Marketplace|MYOB AccountRight API Endpoint Doc's



Did my answer help?


Mark it as a Solution

Viital
Contributing User
5 Posts
Contributing User
Contributing User

5Posts

0Kudos

0Solutions

Re: Attaching PDF to bill API

Hi Hannah,

 

I have tried both ways as provided in your link below. Both return the same error.

 

The first example is what I have been using previously and this has been working fine.

 

AttachmentArray
  OriginalFileNameString
  FileBase64ContentString

 

and

 

{
"Attachments": [
{
"OriginalFileName": "Reece.pdf",
"FileBase64Content": "J..KJH"
}
]
}

Didn't find your answer here?

Try using advanced search to find a post more easily Advanced Search
or
Get the conversation started and make a new post Start a Post