This information is aimed to developers only. If you're not a developer, you probably don't need to know about all this.

Example: getting a product


If you click on the JSON link of the ProductGet function, you'll see this screen: https://api.megaventory.com/v2017a/json/metadata?op=ProductGet and in this screen you'll also see that you need to POST to: /json/reply/ProductGet with the JSON payload:

"APIKEY":"String","ProductSKU":"String","ProductCategoryID":0,"ProductMainSupplierID":0,"includeReferencedObjects":false,"query":"String"

So, a simple JSON call to return your products, would be this one: https://api.megaventory.com/v2017a/json/reply/ProductGet?APIKEY=YOURAPIKEYHERE

Example: inserting a client

A JSON call to Insert a client would be this one:

https://api.megaventory.com/v2017a/json/reply/SupplierClientUpdate?APIKEY=YOURAPIKEYHERE&mvSupplierClient={SupplierClientID:0,SupplierClientType:Client,SupplierClientName:API_client,SupplierClientBillingAddress:Some%20Billing%20Field}&mvRecordAction=Insert

basically a POST to https://api.megaventory.com/v2017a/json/reply/SupplierClientUpdate with the following payload:

APIKEY=YOURAPIKEYHERE&mvSupplierClient={SupplierClientID:0,SupplierClientType:Client,SupplierClientName:API_client,SupplierClientBillingAddress:Some Billing Field}&mvRecordAction=Insert

Example: get products with available quantity

To get the products with available quantity you can run this API call:

https://api.megaventory.com/v2017a/json/reply/InventoryLocationStockGet?APIKEY=YOURAPIKEYHERE&ShowOnlyProductsWithPositiveQty=1

You will get a response with all available products. Also, if you notice, there is a "query" parameter. This simulates more or less an SQL query. For example:

https://api.megaventory.com/v2017a/json/reply/InventoryLocationStockGet?APIKEY=YOURAPIKEYHERE&ShowOnlyProductsWithPositiveQty=1&query=mv.ProductSKU like '%000%'

will bring products with positive quantity that include the '000' anywhere in the ProductSKU field. The thing to note is the mv. prefix that needs to be added before the usual fields that you'll find in the syntax of each API call.

Example: get suppliers or clients

For the SupplierClientGet:

https://api.megaventory.com/v2017a/json/reply/SupplierClientGet?APIKEY=YOURAPIKEYHERE&query=mv.SupplierClientName like '%mag%'

will bring all suppliers/clients that include 'mag' in their name. You can also use an AND/OR:

https://api.megaventory.com/v2017a/json/reply/SupplierClientGet?APIKEY=YOURAPIKEYHERE&query=mv.SupplierClientName like '%mag%' AND mv.SupplierClientType = 2

(mv.SupplierClientType = 2 is for strictly clients, mv.SupplierClientType = 1 is for strictly suppliers, mv.SupplierClientType = 0 is for entities that are both suppliers and clients).

A general note

Finally, you will notice that most API functions have an Update call (such as SupplierClientUpdate) with an "mvRecordAction" parameter. This can either be mvRecordAction=insert (create/insert) or mvRecordAction=update.

The metadata definition (JSON again) of the SalesOrderGet/SalesOrderUpdate is here:

https://api.megaventory.com/v2017a/json/metadata?op=SalesOrderGet
https://api.megaventory.com/v2017a/json/metadata?op=SalesOrderUpdate

So, to get the SalesOrderClientID you should first call the SupplierClientGet (with the name of the supplier/Client) and extract the id. Same with the SalesOrderInventoryLocationID. Alternatively, you can store Ids locally upon an initial sync.

Did this answer your question?