Solved

Fetching Data from Acumatica - REST API

  • 13 April 2024
  • 7 replies
  • 85 views

Hi Team,

I'm trying to pull data from Acumatica and use it for further processing at my backend system (similar to SAP in this case). I need to retrieve data from multiple entities like companies, projects, and employees.

I successfully made API calls using Postman to fetch specific entities, like projects. However, when I attempt the same call through the Extended endpoint, I receive a 500 Internal Server Error.

Could someone advise on the best approach to fetch data from multiple entities, including using the Extended endpoint?

icon

Best answer by jinin 22 April 2024, 20:19

View original

7 replies

Badge +18

Hello,

Did you see these prior post related to error 500? It seems like error 500 is followed by another more detailed message.  We may need to know the second part of your error, to best answer. 

Second error in the first post below is

"exceptionMessage":"Object reference not set to an instance of an object."

 

In second case, answered by jinin, 500 error is followed by "The given key was not present in the dictionary." 

In the third case, error 500 is followed by "String or binary data would be truncated in table 'AcumaticaDB.dbo.SOShipment', column 'UsrRWSStatus'. Truncated value: 'P'.\r\nThe statement has been terminated."

If you want to search further, I used “500 internal error” -- your results will be more accurate if you search a few words from your second error.  Good luck!

Laura

Userlevel 7
Badge +11

Hi @Subbu ,

Refer to the below documents,
 

https://help.acumatica.com/(W(9))/Help?ScreenId=ShowWiki&pageid=709351cc-566a-47b3-b153-3a9fdd690ce0

 

https://help.acumatica.com/(W(10))/Wiki/ShowWiki.aspx?pageid=c450492e-06fe-4563-95c3-efa76975415b

https://stackoverflow.com/questions/60062050/acumatica-rest-api-how-to-include-extended-data-when-retrieving-stockitem

@Laura02  - Attaching the response body here, and I've extended the endpoint and tried to get the data from GIProject, which is a generic inquiry.

{

    "message": "An error has occurred.",

    "exceptionMessage": "Optimization cannot be performed.The following fields cause the error:\r\nProjectID: View Results has BQL delegate\r\nCustomer: View Results has BQL delegate\r\nDescription: View Results has BQL delegate\r\n",

    "exceptionType": "PX.Api.ContractBased.OptimizedExport.CannotOptimizeException",

    "stackTrace": "   at PX.Api.ContractBased.OptimizedExport.NotWorkingOptimizedExportProvider.get_CanOptimize() in C:\\build\\code_repo\\NetTools\\PX.Api.ContractBased\\OptimizedExport\\NotWorkingOptimizedExportProvider.cs:line 93\r\n   at PX.Api.ContractBased.EntityService.<GetListAsyncFromEnumerable>d__8.MoveNext() in C:\\build\\code_repo\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 249\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at PX.Api.ContractBased.SystemContracts.V2.Facade.<PX-Api-ContractBased-IRestGate-GetListAsync>d__2.MoveNext() in C:\\build\\code_repo\\NetTools\\PX.Api.ContractBased\\SystemContracts\\V2\\Facade.cs:line 34\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__1`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"

}

@Laura02 @jinin @ruchikasharma23  - regarding fetching generic inquiries using Postman. I'm encountering an error, and I'd appreciate your assistance.

 

My Questions:

  1. I created a simple generic inquiry and would like to retrieve the data using Postman. Can you guide me on the correct approach?
  2. Is it possible to fetch data from multiple entities, such as SalesOrders and Projects, in a single API call?
     

     

Userlevel 7
Badge +11

Hi @Subbu ,

#1 
Follow the steps given in the blog. Accessing Data in Generic Inquiries using Contract Based API’s (acumatica.com)

#2 NO. We cannot fetch multiple entities in a single endpoint.
 

Userlevel 5
Badge +2

@Subbu 
You could also use OData to retrieve data from GI.
GET: {sitename}/OData/GIProjects
More information here: https://help.acumatica.com/(W(1))/Help?ScreenId=ShowWiki&pageid=5d97a93d-45e0-466e-ba5e-77e1ccf96643

@jinin @ruchikasharma23  - Thank you both! I tried the provided solutions and it worked!

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