Method Community

 

How to Create an Item from API?

Last post 01-20-2023 4:37 PM by Method_Paul. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-19-2023 1:47 PM

    How to Create an Item from API?

    I have been using the Method API for a couple years now and even when things are not clearly documented I have been able to figure them out from the examples in the API docs. However I have not been able to successfully create an Item through the API. 

    For example, I tried posting this item with this API call: 

    curl --location --request POST 'https://rest.method.me/api/v1/tables/item' \

    --header 'Authorization: APIKey ***' \
    --header 'Content-Type: application/json' \
    --data-raw '{
    "ItemType": "Inventory",
    "FullName": "dB Technologies USA Inc",
    "IsActive": true,
    "Name": "dB Technologies USA Inc",
    "PurchaseCost":"0",
    "SalesDesc": "",
    "QuantityOnHand": "1",
    "IncomeAccount": "Integration:Sales",
    "COGSAccount": "Cost of Goods Sold",
    "AssetAccount": "Inventory Asset-1",
    "PrefVendor_RecordID": 4377
    }
    '

    It sucessfully creates a new record, but there is no Name or Description. The other fields do show up. 

    What do I need to change to be able to create a new Item so the name and description shows up? 

    Does someone have an example API post? 

  • 01-19-2023 2:12 PM In reply to

    Re: How to Create an Item from API?

    Jamie - I'll try a quick answer before the support and/or product teams chime in. On first glance, I would try a few things:

    a) Don't include FullName. FullName is really a calculated field. It figures out FullName based on the Name as as well as the reference to a Parent, if there is one.  I wonder if including FullName is throwing it off somehow, and somehow causing the Name to be blank.

    b) I would try not including PrefVendor_RecordID, QuantityOnHand for now to see if that makes a difference. Those are bonus fields...introduce them one at a time to something that is working.

    c) Description - on Inventory, you want to set both the purchase description as well as the sales description. They might be different.  In your example, your description was an empty string, so makes sense.

    Hopefully that helps. 

  • 01-19-2023 2:41 PM In reply to

    Re: How to Create an Item from API?

    I tried this all the way down to just one field and have not found a way to get the Item Name or Description to add. 

    curl --location --request POST 'https://rest.method.me/api/v1/tables/item' \
    --header 'Authorization: APIKey **' \
    --header 'Content-Type: application/json' \
    --data-raw '{
    "Name": "dB Technologies USA Inc"
    }
    '

    I tried just SalesDesc, etc. and none populate the Item Desc field. 

  • 01-20-2023 4:37 PM In reply to

    Re: How to Create an Item from API?

    Here's the trick, you need to add to the ItemInventory table, not the Item table. Kinda confusing....but the Item table is more of a "view" of all the types of item tables.  And yes, we should be making that more obvious via the API.

    I tried, using PostMan to create an item in the ItemInventory table, and can confirm that Name, Purchase Description and Sales Description all showed up perfectly.

    "Name": "Test Item3",
    "IsActive": true,
    "IncomeAccount": "Integration:Sales",
    "AssetAccount": "Inventory Asset-1",
    "COGSAccount" : "Cost of Goods Sold",
    "IsTrackQtyOnHand" : true,
    "PurchaseCast" : 0,
    "SalesPrice" : 0,
    "PurchaseDesc" : "This is a purchase description.",
    "SalesDesc" : "This is a sales description."
Page 1 of 1 (4 items)