Forum Discussion

The_Doc's avatar
The_Doc
Ultimate Partner
2 years ago
Solved

API Question - POST Item

Hi Folks

 

Thought I might get lucky with an API knowledgeable user able to answer this question quickly.

 

I am an API developer and GET and POST many things via the API, however, I have never POSTed an inventory item change via the API.

 

Inventory updates are easy via the import facility and you only require the MYOB Number as an mandatory field.

 

The endpoint information on the Developers web is NOT easy to understand so that when I have to use a new Endpoint POST I only get it right by trial and error and filtering the errors returned - correcting these and trying again.

 

I need to POST back to a live MYOB file running a fully configured inventory system 2 fields regularly from an integrator I have running.

 

Custom List 2 and item Standard Cost.

 

The Developer endpoint info shows 2 mandatory fields 

 

1. item UID ( no problem)

2. MYOB Number (again no problem) - easy though I have asked through the Developers email why they need 2 mandatory fields - if we only needed the UID we would have a means to bulk update MYOB Numbers which we cannot do via the import feature - that is an aside)

 

My question - the document is not clear - and I am trying to cut the trial and error out here - do I need any other information to POST these updates.

 

The Doc

 

  • Hi The_Doc , updating existing items is done via a PUT operation. According to https://developer.myob.com/api/myob-business-api/v2/inventory/item/, "Items shown with [tick] are required when posting or puting data".

     

    It would pay to expand the page display to show all the element notes. (Click the link at the end - "To view the descriptions for the elements you can either hover (over) any attribute to reveal details or click here to show all details")

     

    You'll definitely need to include the row version, which should be obtained immediately prior to the PUT operation. I'm not sure that all the other UIDs (ticked) are required, but a trial (using Postman?) should confirm that.

4 Replies

Replies have been turned off for this discussion
  • Mike_James's avatar
    Mike_James
    Ultimate Partner

    Hi The_Doc , updating existing items is done via a PUT operation. According to https://developer.myob.com/api/myob-business-api/v2/inventory/item/, "Items shown with [tick] are required when posting or puting data".

     

    It would pay to expand the page display to show all the element notes. (Click the link at the end - "To view the descriptions for the elements you can either hover (over) any attribute to reveal details or click here to show all details")

     

    You'll definitely need to include the row version, which should be obtained immediately prior to the PUT operation. I'm not sure that all the other UIDs (ticked) are required, but a trial (using Postman?) should confirm that.

    • The_Doc's avatar
      The_Doc
      Ultimate Partner

      Hi Mike

       

      I reactivated this post - the accepted answer, the one you gave turned out to be a little far from reality - not of your doing.

       

      MYOB's API Endpoint Notes and examples are woefully in error and lacking the information I needed and yourself to answer this question

       

      I have battled other endpoints and have never been beaten in getting one coded and working - not to say that is due to MYOB's endpoint examples and notes - quite the opposite - due to just persisting until things worked.

       

      Well I did that with the 'PUT'   inventory/item update endpoint through the API - and NOTHING WORKED - nothing.

       

      A month later - thinking everyday I would 'get it' - I never did. None of my old tricks worked - it just continued to error

       

      I added ALL manadatory parameters as indicated by the website notes - and finally yesterday braved an email to the developers email site - to be told - sorry from 1 Jul 22 you needed to include your Developers ID and this email account is no longer monitored - you have to post a ticket.

      No problem - I posted a ticket - was easy - just cut and paste from my email.

      Reply from ticket system - Thank you - we will reply within 48 hrs except public hols etc. - but hey go to the Developers API endPoint notes etc.....

       

      I waited - and in 24 hrs - Hannah cherry reply was waiting in my email folder - the jist of the reply.

       

      Yep Howard the Developer API EndPoint notes are woefully dated and 'we are updating those but can't give a timeframe for completion' - however in reply to your POST - here is an example of the required PUT - the answer

       

      The PUT had to be FULL BODIED - EVERY FIELD populated else the update ( which was only for the Purchase Standard Cost' )  would wipe out ALL the existing data.

       

      Wow - that blows me away in logic - noting that a manual update through the import/export facility allows you to update distinct data fields so long as you include the ItemNumber.

       

      However the end point requires you to load the entire Inventory data table with existing data and obviously the field you are changing.

       

      I haven't tried it because the code to build the PUT body is going to be quite complex - nothwithstanding the need to download ALL this data for the said items so you can populate the PUT fields.

       

      Hmm - my brain is reeling from that bombshell note.

       

      The Doc ( shell shocked and in PTMURSS) Post Traumatic MYOB Update Requirement Shell Shock)

       

      PS - I will update this post when I have success with a single update item - you will hear the scream