Skip to main content
Solved

Fetching Data from Acumatica - REST API


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?

Best answer by jinin

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.
 

View original
Did this topic help you find an answer to your question?

7 replies

Laura02
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3132 replies
  • April 14, 2024

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


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 706 replies
  • April 14, 2024

  • Author
  • Freshman I
  • 4 replies
  • April 14, 2024

@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()"

}


  • Author
  • Freshman I
  • 4 replies
  • April 22, 2024

@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?
     

     


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 706 replies
  • Answer
  • April 22, 2024

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.
 


Forum|alt.badge.img+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


  • Author
  • Freshman I
  • 4 replies
  • April 23, 2024

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings