Search code examples
acumatica

How can I retrieve a file from a Bills and Adjustments attachment using Contract Web services


I've successfully retrieved a file from the Stock Items screen using the Contract Based Web Services example provided by Acumatica. My question is about the syntax for the Bills and Adjustments screen to do the same thing. The code in question is here:

For the Stock Items, the syntax is:

string stockItem = rs.GetByKeys("StockItem", inventoryID, "$expand=files");

And the GetByKeys call is:

public string GetByKeys(string entityName, string keys, string parameters)
{
    var res = _httpClient.GetAsync(
    _acumaticaBaseUrl + "/entity/Default/20.200.001/" + entityName + "/" + keys + "?" + parameters).Result.EnsureSuccessStatusCode();

    return res.Content.ReadAsStringAsync().Result;
}

Where the entityName is "StockItem" and keys value is the inventory ID.

So, my question is, to use the Bills and Adjustments screen, what would the keys value be (maybe the RefNbr?) and what would the entityName be (maybe "Bills"? - does that refer to something in the endpoints screen?)?

Thanks...


Solution

  • The endpoint entity is Bill.

    You can use SQL to identify the endpoint entity for a target ScreenID:

    select ObjectName from EntityDescription where ScreenID = 'AP301000'
    

    enter image description here

    The key values are the same that are used in the DAC/Table.

    In this case it is APInvoice.DocType and APInvoice.RefNbr (CompanyID being a system key which is ignored):

    enter image description here

    The keys need to be separated by a slash character '/' in the URL and provided in the same order. Example for 'Bill 002789' would be 'INV 002789', INV being the doc type code and 002789 the RefNbr:

    http://localhost/Acumatica/entity/Default/20.200.001/Bill/INV/002789?$expand=files