Forum Discussion

PolarBear1's avatar
6 months ago

Posting Supplier to MYOB AccountRight

Dear Fellow Developers and MYOB Community Managers,

 

I have been trying to POST a new Contact/Supplier to MYOB using the API.

I have copied and paste the Body provided by the sample Postman Collection, however, I continue to get the error: "A body is required during a PUT or POST operation"

Can I seek some guidance?

 

Much Appreciated,

PolarBear1

  • Will_H's avatar
    Will_H
    MYOB Moderator

    Hi PolarBear1 ,

    I'm not from AccountRight support, never used that section of our APIs, so please defer to anyone else who replies here.

    But my 2 questions I have for this scenario are:

    1. What endpoint is being queried?   The screenshot doesn't show the actual request address.
    2. What headers were you specifying?  I've seen similar errors from other APIs I deal with when I failed to specify the Content-Type header and my assumed formatting was rejected by the API providers defaults.


    Endpoint documentation for that API should be here:

    https://developer.myob.com/api/myob-business-api/v2/contact/supplier/

    Postman collection for that API is here:
    https://developer.myob.com/api/myob-business-api/accountright-postman-collection/


    API support home is here:
    https://apisupport.myob.com/hc/en-us 

    Regards,
    Will H 
    Enterprise Product Platform Liaison

  • Hi Will_H ,

    Good day to you! Thank you for your reply.

     

    1. What endpoint is being queried?
    I am using the endpoint /{cf_uri}/Contact/Supplier

    https://arl2.api.myob.com/accountright/${myobCompanyFileId}/Contact/Supplier

    2.  What headers I am specifying?

    headers: {
    'Authorization': `Bearer ${token.access_token}`,
    'x-myobapi-key': clientId,
    'x-myobapi-version': 'v2',
    'Accept-Encoding': 'gzip,deflate',
    'Content-Type': 'application/json'
    }

    Thank you for the links that you have sent. I have browsed through them and would like to give some feedback.

     

    Endpoint documentation for that API should be here:

    https://developer.myob.com/api/myob-business-api/v2/contact/supplier/

    This is the official MYOB Documentation Webpage, but it is outdated. The Documentation states that only CompanyName is required when IsIndividual is false. However POSTing a body like 

    {
    CompanyName: "PolarBear",

    IsIndividual: false


    Will result in the same error as above

    For the Postman link, I would like to thank the MYOB Team for creating this collection. I have heavily referenced it in my building of API Calls.

    I copied the Body of the example of the contact/supplier API End Point in the Postman Collection but still get the same error as shown in my original post.

    Thanks again for your reply and hope to hear from you soon!