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:

 

{"Filters":[{"AndOr":"And","FieldName":"String","SearchOperator":"Undefined","SearchValue":"String"}],"APIKEY":"String","ProductID":0,"ProductSKU":"String","ProductCategoryID":0,"ProductMainSupplierID":0,"includeReferencedObjects":false}


So, a simple JSON call to the ProductGet will return all of your products:


https://api.megaventory.com/v2017a/json/reply/ProductGet?APIKEY=YOUR_API_KEY_HERE


The following call uses the Filters property to call the ProductGet function by quering the ProductSKU fieldname with a SearchValue of AT1FX01W15. The product that equals 'AT1FX01W15' will be returned.

    
https://api.megaventory.com/v2017a/json/reply/ProductGet?APIKEY=YOUR_API_KEY_HERE&Filters={FieldName:ProductSKU,SearchValue:AT1FX01W15}


The following call uses the Filters attribute to call the ProductGet function by quering the ProductSKU fieldname with a SearchOperator of Contains and a SearchValue of FX01W. The products that contain 'FX01W' will be returned.

    
https://api.megaventory.com/v2017a/json/reply/ProductGet?APIKEY=YOUR_API_KEY_HERE&Filters={FieldName:ProductSKU,SearchOperator:Contains,SearchValue:FX01W}


The following call uses the Filters attribute with multiple filters to call the CurrencyGet function by quering the CurrencyDescription fieldname with a SearchOperator of Contains and a SearchValue of EUR. Another subsequent filter uses the CurrencyCode fieldname with a SearchOperator of Equals and a SearchValue of USD with the AndOr operator set to Or. The currencies that contain 'EUR' in the currency description or equal 'USD' in the currency code fields will be returned.

    
https://api.megaventory.com/v2017a/json/reply/CurrencyGet?APIKEY=YOUR_API_KEY_HERE&Filters=[{FieldName:CurrencyDescription,SearchOperator:Contains,SearchValue:EUR},{AndOr:Or,FieldName:CurrencyDescription,SearchOperator:Equals,SearchValue:USD},{AndOr:Or,FieldName:CurrencyCode,SearchOperator:Equals,SearchValue:USD}]



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. You can still use the Filters property to create more sophisticated queries.


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


A SalesOrderUpdate call would look like:


https://api.megaventory.com/v2017a/json/reply/SalesOrderUpdate?APIKEY=YOURAPIKEYHERE&mvRecordAction=Update&mvSalesOrder={SalesOrderId:1008,SalesOrderNo:7,SalesOrderDate:\/Date(1487973600000-0000)\/,SalesOrderCustomOrderDate1:\/Date(-62135596800000-0000)\/,SalesOrderCustomOrderDate2:\/Date(-62135596800000-0000)\/,SalesOrderCurrencyCode:USD,SalesOrderClientID:3,SalesOrderBillingAddress:1 Infinite Loop Cupertino CA 95014,SalesOrderShippingAddress:1600 Amphitheatre Parkway Mountain View  CA,SalesOrderContactPerson:Name of Contact Person,SalesOrderInventoryLocationID:1,SalesOrderCustomFlag1:false,SalesOrderCustomFlag2:false,SalesOrderCustomFlag3:false,SalesOrderCustomFlag4:false,SalesOrderCustomFlag5:false,SalesOrderTotalQuantity:1,SalesOrderAmountSubtotalWithoutTaxAndDiscount:0.00,SalesOrderAmountShipping:0.00,SalesOrderAmountTotalDiscount:0.00,SalesOrderAmountTotalTax:0.00,SalesOrderAmountGrandTotal:10.00,SalesOrderStatus:Verified,SalesOrderDetails:[{SalesOrderRowProductSKU:dvd-sw6,SalesOrderRowProductDescription:Some Product Description 1,SalesOrderRowQuantity:1.000000000,SalesOrderRowShippedQuantity:0.000000000,SalesOrderRowInvoicedQuantity:0.000000000,SalesOrderRowUnitPriceWithoutTaxOrDiscount:10.000000000,SalesOrderRowTaxID:0,SalesOrderTotalTaxAmount:0.0000,SalesOrderRowDiscountID:0,SalesOrderRowTotalDiscountAmount:0.0000,SalesOrderRowTotalAmount:10.0000},{SalesOrderRowProductSKU:dvd-sw5,SalesOrderRowProductDescription:Some Product Description 2,SalesOrderRowQuantity:2.000000000,SalesOrderRowUnitPriceWithoutTaxOrDiscount:10.000000000,SalesOrderRowTaxID:0,SalesOrderTotalTaxAmount:0.0000,SalesOrderRowDiscountID:0,SalesOrderRowTotalDiscountAmount:0.0000,SalesOrderRowTotalAmount:20.0000}]}


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.