API Question - POST Item

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.
The_Doc
Ultimate Partner
1,537 Posts
Ultimate Partner
Australia
Ultimate Partner

1,537Posts

236Kudos

162Solutions

Solved: Go to Solution

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

 

4 REPLIES 4
Mike_James
Ultimate Partner
5,839 Posts
Ultimate Partner
New Zealand
Ultimate Partner

5,839Posts

1,080Kudos

755Solutions

Accepted Solution Solved

Re: API Question - POST Item

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.


Regards, Mike (mike@datawise.co.nz)
DataWise Limited (www.datawise.co.nz), developers of:
DataWise ProActive - Custom Reporting from MYOB programs
(MYOB Business, including AccountRight Live, AccountRight v19.x and exo Payroll)

Bulk download of attachments (more details...)

The_Doc
Ultimate Partner
1,537 Posts
Ultimate Partner
Australia
Ultimate Partner

1,537Posts

236Kudos

162Solutions

Re: API Question - POST Item

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

Mike_James
Ultimate Partner
5,839 Posts
Ultimate Partner
New Zealand
Ultimate Partner

5,839Posts

1,080Kudos

755Solutions

Re: API Question - POST Item

Hi @The_Doc , thanks for put-ting me straight! And on Australia Day too!

 

Digging deeper with Google, I found this 2016 forum post: https://community.myob.com/t5/MYOB-Business-API/Updating-records-using-PUT/td-p/413919

This confirms what MYOB told you.

 

 


Regards, Mike (mike@datawise.co.nz)
DataWise Limited (www.datawise.co.nz), developers of:
DataWise ProActive - Custom Reporting from MYOB programs
(MYOB Business, including AccountRight Live, AccountRight v19.x and exo Payroll)

Bulk download of attachments (more details...)

The_Doc
Ultimate Partner
1,537 Posts
Ultimate Partner
Australia
Ultimate Partner

1,537Posts

236Kudos

162Solutions

Re: API Question - POST Item

Hi @Mike_James 

 

No problem - always happy to correct or be corrected - interestingly MYOB has never quite made that clear.

 

At least I retain some of my hair having pulled patches out in the last month and wasted enormous time hoping to solve the problem and time slips away.

 

You may be interested in why I am doing it - well, firstly I opened my developer yappa to a client who asked me if something was possible in his wishlist - and I said yep!!!

 

A new webcart selling from an live MYOB perpetual inventory system - pricing is based on purchase standard cost - and wanting to beat the inevitable supplier general price rise on all their supplied products dribbling through as new orders reflect the price change - through the MYOB to Web integrator I have built being able to select a supplier - and all products supplied and applying a increase factor to the Standard purchase prices as a bulk update - loading them into the web - then flushing these new Std Prices back to the parent MYOB file and products they apply to ( because if we don't the old price coming through wipes out the new Std price).

 

I suppose we could disallow an update coming from MYOB overwriting if less than the new one - hmm might work - would save agony of writing inventory back to MYOB.

 

Regards The Doc

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