0

How can I run a generic inquiry that I created via Acumatica's REST API? I was using the Inventory Summary Inquiry before but it was not returning all of the data I needed so we created a Generic Inquiry to return available for shipment quantity for ALL stock items. However I can't find how to get the data from this report via the API.

UPDATE:

I've tried creating an extended endpoint service and adding my endpoint for the report as described in I210 Documentation and then hitting via the REST API (which is not shown in I210). I added all of the result fields to the fields tab of the endpoint that I need returned.

Here are the details I used:

Extended Endpoint Name: MyInventoryAvailable
Endpoint version: 6.00.001
Endpoint: GetAvailableInventory
URL: https://mycompany.acumatica.com/entity/MyInventoryAvailable/6.00.001/GetAvailableInventory?$expand=Results

When I do a PUT request using the above details, this is the response I get:

{
    "message": "The request is invalid.",
    "modelState": {
        "": [
            "The request body should not be empty."
        ]
    }
}

UPDATE 2

Here is the setup in Acumatica for the extended endpoint: enter image description here

I've tried setting up a request body but with no success:

{
    "InventoryID": {
        "Value": "AB-CL-60"
    },
    "Description": {
        "Value": ""
    },
    "Location": {
        "Value": ""
    },
    "QtyHardAvailable":{
        "Value": 0.0
    },
    "QtyOnHand":{
        "Value": 0.0
    },
    "Warehouse":{
        "Value": 0.0
    }
}

When sending any request body, regardless of the content I recieve this error:

"exceptionMessage": "The given key was not present in the dictionary.",
"exceptionType": "System.Collections.Generic.KeyNotFoundException",

UPDATE 3 - Inquiry Structure

Here is the structure of the inquiry: enter image description here

And here are the results in Acumatica's UI: enter image description here

UPDATE 4

Expanded GetAvailableInventory node: enter image description here

big_water
  • 3,024
  • 2
  • 26
  • 44
  • What have you tried and it failed? Inquiry operations are described in the I210 training and Help. – Sergei Rogovtcev Jan 25 '18 at 08:33
  • I210 does not describe how to do this via the REST API. – big_water Jan 25 '18 at 15:32
  • Please see updated question above @SergRogovtsev – big_water Jan 25 '18 at 19:20
  • So, the error clearly states what you're doing wrong: apparently, not sending any body. What body are you sending? – Sergei Rogovtcev Jan 25 '18 at 19:23
  • I am not sending a body. There should be no body required...there are no parameters required to run this report that I am aware of @SergRogovtsev – big_water Jan 25 '18 at 19:23
  • The body _is_ required; when no parameters, you have to send an empty object (`{}`) body. – Sergei Rogovtcev Jan 28 '18 at 00:11
  • @SergRogovtsev, by removing the $expand=results parameter, it allowed me to pass {} as the body. However, I only got the first row back from the inquiry. How can I get all rows via the API call? (p.s. thanks for your help) – big_water Jan 29 '18 at 13:50
  • What is the structure of `GetAvailableInventory`? – Sergei Rogovtcev Jan 29 '18 at 23:41
  • @SergRogovtsev, I've updated the question with the structure (or so I believe). Let me know if you were looking for something else. – big_water Jan 30 '18 at 13:56
  • What is the structure of the _C-b API entity_ `GetAvailableInventory` you've mapped? – Sergei Rogovtcev Jan 31 '18 at 15:59
  • @SergRogovtsev, I believe I've already posted that under Update 2. Correct me if I'm wrong or direct me how to get you what you're looking for. – big_water Jan 31 '18 at 16:33
  • Expand the `GetAvailableInventory ` in the tree so that we can see whether you have any detail nodes. – Sergei Rogovtcev Jan 31 '18 at 19:45
  • @SergRogovtsev See updated image above. I do not have any details nodes on the GetAvailableInventory endpoint. Should I? – big_water Jan 31 '18 at 19:59
  • Yes, you should. The should be an example in I210 on how to map Inquiry screens, but basically should have a detail entity mapped to the results grid, not the top-level one. – Sergei Rogovtcev Jan 31 '18 at 20:32
  • @SergRogovtsev, it's not a question of whether I can get the data back. I'm am getting the data I want for *one* item. I want to get the data back for *ALL* items in one call to the endpoint. Just like when I run the Inventory Available generic inquiry, it prints out *all* of the items inventories. What do I need to do to get *ALL* rows back from this generic inquiry?? – big_water Jan 31 '18 at 21:19
  • Map it correctly. The way you've done it you won't be able to. – Sergei Rogovtcev Jan 31 '18 at 21:32
  • @SergRogovtsev, "Map it correctly" is not a helpful answer. If I knew how to do that, it would be working. I've gone through the examples in I210 that you're referring to and none of them provide an example or description of how to map these to return all rows. Please provide an answer that shows an example mapping of how to return all rows. – big_water Jan 31 '18 at 21:38
  • 1
    @big_water, aren't you supposed to use "GET" instead of "PUT" ? and are you using Postman to test your APIs ? – Rick Jan 31 '18 at 23:22
  • @Rick, I'll be damned....using GET worked! The documentation clearly states to use the PUT method for running inquiries as shown [here](https://help.acumatica.com/(W(25))/Wiki/ShowWiki.aspx?pageid=6340cff3-4732-4231-9e42-5d1e5e65b5dd). Thank you for your suggestion! If you want to add it as an answer I will accept it. Acumatica has some work to do in order to have complete and correct documentation available to developers. – big_water Feb 01 '18 at 13:43
  • @SergRogovtsev, if it was you that downvoted this question, I'd appreciate it if you removed the downvote. I think others who are trying to do perform a similar operation with Acumatica will find this question helpful and downvoting will discourage people from finding this. – big_water Feb 01 '18 at 13:59
  • @Rick, one should use `PUT` with inquiry screens. `GET` is for data entry/plain list screens. – Sergei Rogovtcev Feb 01 '18 at 14:39
  • @big_water, the `Default/17.200.001` endpoint shipped with Acumatica 2017R2 has an `AccountSummaryInquiry` (among others) which can be used as an example. On 6.1 there's `InventorySummaryInquiry`. – Sergei Rogovtcev Feb 01 '18 at 14:47
  • @SergRogovtsev, the *second line* of my question states why I can not use the `InventorySummaryInquiry`... – big_water Feb 02 '18 at 14:12
  • @big_water, my reference to `InventorySummaryInquiry` was to give you an example of how the inquiries (whether inquiry screens or GIs) are supposed to be mapped. – Sergei Rogovtcev Feb 02 '18 at 14:32
  • @SergRogovtsev, ok I see. I did try copying the structure of the `InventorySummaryInquiry` but it ended up functioning just like that inquiry and only returned one row. I really need it to return all rows of the inquiry which is what the `GET` method accomplished. Thank you for trying to help, but it appears there is not an "intended" solution for this question. Can we expect a solution to this in a future release? Would you like me to submit a support ticket so this is on Acumatica's radar for feature requests? – big_water Feb 02 '18 at 14:46
  • To return all rows from the inquiry, use {{PUT}} request (or {{Put}} method in SOAP) as shown in Example 3.2.1 (Retrieving the Quantities of a Stock Item) of the I210 training or the `InventoryDataRetriever.ExportItemQty` method of the accompanying `MyStoreRestIntegration` solution. – Sergei Rogovtcev Feb 02 '18 at 15:05

2 Answers2

3

This is how I structure Generic-Inquiries in Web-Service-Endpoints.

While other Endpoints contain any number of Mapped Objects, the Generic-Enquiry Endpoints only have

Enter-Keys, Filter, Result, and Values-for-Update

The FIELDS for the ENDPOINT are the Filters (click POPULATE -> Filters). The example above does not seem to have any filters, which is fine, so this FIELDS should be empty.

To get the data from the Generic Inquiry, a "Detail" entity is added

  • click the Generic Inquiry
  • click "+ INSERT"
  • Fill in form with FieldName='GetAvailableInventoryResults', ObjectName='GetAvailableInventoryResults', ObjectType=Detail
  • Save

Now, add the results wanted by clicking on 'GetAvailableInventoryResults', then FIELDS (opens a popup). In the popup, select 'Result' and add all the fields you want. Don't select "Row Number" and "Selected" as these are not needed and can cause errors. SAVE.

To access the ENDPOINT, do a PUT to

   .../GetAvailableInventory?$expand=GetAvailableInventoryResults

with a BODY of

{}

since this ENDPOINT does not define any Filters, but a PUT requires this to exist.

Why do I use "GetAvailableInventoryResults"? Well, because I ran into issues with multiple Generic-Inquiry Endpoint's having Details with the same name, so I make sure they are all unique.

J. McNerney
  • 576
  • 4
  • 15
-3

Use GET instead of PUT. Your requirements fall under this. I supposed Generic Inquiry <> Inquiry Form. Hence the different outcome between GET vs PUT.

Rick
  • 1,301
  • 1
  • 16
  • 28
  • `GET` requests are not supposed to work properly for Generic Inquiry. – Sergei Rogovtcev Feb 02 '18 at 02:30
  • just what are you talking about @SergRogovtsev ? I have numerous end points based on generic inquiries and they all work fine on GET. – Rick Feb 02 '18 at 03:18
  • @SergRogovtsev, just because *you* can't provide a solution because your software doesn't work as intended is no reason to downvote an answer and call it an invalid solution because it *does* in fact work. This will be the accepted answer until you can either fix your software and/or provide a solution that works based on your intended methods. And please stop downvoting valid questions and answers. You're discouraging the public from helping to support your software on a public forum! – big_water Feb 02 '18 at 13:58
  • @Rick, I am happy to know that you've found a way to implement something that works for you, but I have to advise you that, unfortunately, it is not the way it is supposed to work, so it might break unexpectedly. – Sergei Rogovtcev Feb 02 '18 at 14:30