Solved

REST API Assistance


Userlevel 6
Badge +3

Have been trying to retrieve the data from the Details tab of the Sales Orders(SO301000) screen using the below link with GET request and have been getting the attached screenshot in the response. The requirement is to retrieve the data from the Details tab for all the Sales Orders.

 

URL: /entity/Default/20.200.001/SalesOrderDetails?$expand=Details

 


Kindly let me know how shall I get the list in the Response.

Thank you in advance

icon

Best answer by RohitRattan88 14 April 2023, 16:17

View original

10 replies

Userlevel 7
Badge +4

Hi @Harshita

In the request you need to target the top level entity, and then expand the detail entity. The request URL should be like below,

  • <<Instance URL>>/entity/Default/20.200.001/SalesOrder?$expand=Details

 

To to a filter record based on a field you can use the filter like below,

 

  • /entity/Default/20.200.001/SalesOrder?$filter=OrderNbr eq 'SO006883'&$expand=Details

For more details on the using parameters in the request refer,

Thanks,

Userlevel 6
Badge +3

Thank you @vigneshponnusamy89 for your prompt reply. I did check out with the below mentioned url, but still it lists out the same response. 

  • <<Instance URL>>/entity/Default/20.200.001/SalesOrder?$expand=Details

I would like to retrieve the data based on the following example:
If there are two Sales Orders with IDs SO-001 and SO-002, and each Sales Order has two Line Items, then the API should return a list of four Line Items, which would be the two Line Items associated with SO-001 and the two Line Items associated with SO-002.

Userlevel 7
Badge +4

Hello @Harshita as @vigneshponnusamy89 suggested, make sure you $expand on Details but still use SalesOrder endpoint.

Make sure you do login call before trying to work with REST APIs though.

Here’s and example:

Then you can call the SalesOrder GET :

 

Please refer to I310 for additional details:

I310 Data Retrieval with REST API Basics 2022 R2 (acumatica.com)

Hopefully it helps.

Rohit

Userlevel 6
Badge +3

Thank you @RohitRattan88 for the solution. It worked now. The main issue I was facing was related to the value for Accept & Content Type keys under the Headers section. The values are required to be set to application/json.

Userlevel 6
Badge +3

Hello @vigneshponnusamy89 & @RohitRattan88 
Similarly I have been trying to update the status of the Sales Orders to “Completed” by using a PUT request with the below mentioned URL and request body:

URL: /entity/Default/20.200.001/SOOrder and also tried with /entity/Default/20.200.001/SalesOrder

Request Body: "Status": { "value" : "Completed"}.

But the status isn’t getting updated.

Can you please guide me out in the same?

Thank you in advance.

Userlevel 7
Badge +4

Hello @Harshita,
Completing a Sales Order is an "Action" to be performed which can be done using POST call.
Please refer to I330(I330 Data Manipulation with REST API 2022 R2 (acumatica.com)) for respective documentation.
Rohit

Userlevel 6
Badge +3

Hello Rohit,

I have defined a new Action that is required to be performed as shown below and did try to run a POST request, but still triggering the error 415-Unsupported Media Type

 

URL : /entity/CustomL/20.200.002/SalesOrder/Completed

Kindly let me know what I am missing here.

 

Thank you.

Userlevel 7
Badge +4

@Harshita, Please ensure you have the request body type set to JSON,

 

 

Userlevel 7
Badge +4

@Harshita also make sure you have correct Headers set for the call:

 

Userlevel 6
Badge +3

Thank you @RohitRattan88  for listing out the Header point. I checked out by modifying the Headers and as @vigneshponnusamy89 had mentioned, to set the body type to JSON. I ran the POST request, and looks like it is working now.

But since the button is disabled, the action wont work. But still need to confirm on this if still it could work or not.

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved