HI All,
With Acumatica 6 release you can find (and actually use) new type of API – Rest API.
Acumatica Rest API is based on Contract based API, so here you have some important points:
- You need to use existing or custom endpoint be able to send API calls
- Field and container is available for REST API only if it is defined in contract. But you may extend existing contracts.
- With REST API you have the same set of commands that you have with Contract Based API.
- Acumatica uses Json format for transfer data between client and server
- You still have to maintain session and authentication cookies.
URL: http://<InstanceName>/entity/<EndpointName>/<EndpointVersion>/<Entity>
Example: http://acumatica.com/entity/Default/6.00.001/StockItem
Ok, lest try to do some examples. Here I will show you how to call Acumatica REST commands from Browser. By using this approach you can easily test functionality and just feel, how does it work.
To do so, we need a special tool. I will use PostMan extension for Google Chrome browser.
As we need to maintain session and cookies between calls, we also need to install Postman Interceptor extension.
Login
Now we actually can login. To do so, we need to send our credentials for the specific url:
URL: http://acumatica.com/entity/auth/login
JSON:
{ "name" : "admin", "password" : "123", "company" : "" }
Response should be 204 No Content.
Geting
Ok, authentication is done, lets try to select data.
URL: http://acumatica.com/entity/Default/6.00.001/StockItem
Filtering
If we want some filtering or conditions, we just can use “OData” like filters – $filter=ItemStatus eq ‘Active’
URL: http://acumatica.com/entity/Default/6.00.001/StockItem?$filter=ItemStatus eq ‘Active’&$top=9
Additional parameters that you can use together with URL when you retrieve records from Acumatica ERP:
- $filter: To specify filtering conditions on the records to be returned
- $skip: To specify the number of records to be skipped from the list of returned records
- $top: To specify the number of records to be returned in the list
- $expand: To specify the linked and detail entities to be expanded
- $custom: To specify the fields that are not defined in the contract to be returned
Getting Single Record
If you know key, you can easily get details about single record – just add key field to the url string:
URL: http://acusea.acumatica.com/future/entity/Default/6.00.001/StockItem/AACOMPUT01
Puting
You also can create new entity using REST API, in this case you need to use PUT method and send item details using JSON format. Name of the fields and containers you can get from Contract definition.
URL: http://acusea.acumatica.com/future/entity/Default/6.00.001/StockItem
JSON:
{ "InventoryID" : {value : "Kettler" } , "Description" : {value : "New Cool Kettler" }, "ItemClass" : {value : "ELECCOMP" } }
Documentation
Good news that the documentation on the REST API is included right within standard Acumatica Help. There you can find multiple examples and good code snippets that you can use from your favorite language/platform/code.
Have a nice integration!
Hi. is there any option to have array on entities instead of details?
HI Faizal, I’m not sure I got your question… What do you mean by array instead of details?
Hi Sergey, my question is how can i use api to add multiple new customers by only sending 1 request, instead of looping 1 by 1. because right now i only able to send array in detail screen
Hi Faizal, the only way to import multiple objects with one request is to use old SOAP, Screen-Based API. https://help.acumatica.com/(W(1))/Help?ScreenId=ShowWiki&pageid=7cd68dda-8349-4d7c-a060-4a62b8e519c0
Rest API does not support creation of multiple records at once.
Hey Guys,
I’m struggling with the this issue for a long time now, appreciate if someone could help me. When opening Processing Center screen I don’t see any records under the screen. I have googled and found an article which suggests ‘Integrated Card processing’ to be enabled under Third Party Integrations. I have tried searching for this option under ‘Enable/Disable’ but don’t see it. Am I missing anything?
My user role is administartor , so I believe I should able to see the option..
Vibindas, please try to change the Payment Plugin (Type) field. Remove the value and then add it again or just change back and forth.
When you change it, it should reload the parameters.
Is there a way to add new methods to the interface ICCProfileProcessor? I reckon this is used for Credit Card processing.
Getting the below error when validating entity on Web Service Endpoints. I have mapped newly added column as field to a customized endpoint. Any idea what could be the issue?
“the following fields or parameters may have been mapped incorrectly”
HI Vibindas, your mapped fields should exist in the corresponding DAC. Also, the data view should exist in under the corresponding graph.
If that does not help, please create a support request, our support team should review your code.
Hi,
By using RestAPI , I’m trying to trigger an Action that is defined in the endpoint. I’m trying to figure out how to retrieve the parameters defined in the request body when the action is triggered.
Say for example: if below is the action defined in the graph, how do I get the parameters from the request body. If you could share an example that would be great..
public virtual IEnumerable TestParams(PXAdapter adapter)
{
}
The values in the request body must be mapped to the DAC fields. When you send the API request, Acumatica will automatically pass the parameters to the DAC and set the corresponding values.
Then in the action you should use cache.Current to retrieve values from the corresponding DAC.
any examples that I can refer to please with Action with the above scenario?
Please refer to the existing actions with parameters, such as
– UpdateDiscounts on Discounts form
– ChangeEmployeeID on Employees form
– ConvertLeadToBAccount on the Leads form
I am using the Rest API / getting an exception because there a popup dialog that needs a response. In the api documentation there seems to be a way to ‘send commands’ to respond to dialog boxes using the Screen-Based Soap API. Can’t seem to find the same for the Rest API. Does anyone know if this can be done vis Rest API?
Ted, Did you find a way to respond to the dialog boxes using the Rest API?
We are integrating with the Acumatica SAAS product via the REST API by means of lambda functions. This is working fine in general. However, we find that after a period of inactivity, the response to an API call takes much longer than usual, and our lambda function stops executing before the response is received. An Acumatica support rep once mentioned that this could be due to “cache expiration”, but we can’t find any documentation about this. Is it possible to configure the cache expiration time, or something similar that would help us solve this problem?
Thank you.
Hi Dave,
there is no way to extend the lifetime of internal caches. I think I would recommend you to add an extra warm-up call without timeout before your main call with LINQ. Simple GET should be enough.
Hello,
I am having a few problems, i require the SalesOrderNBR from the Purchase Order. ( /entity/Default/18.200.001/PurchaseOrder )
Using 6.00.001 this was easy as I would specify it in my $custom. However now using 18.200.001 this has now changed and the field is located under Details->custom->UsrSOOrderNbr
Anyone know how i can get the info from Details->custom. I have tried expanding Details and also using $custom but cannot get hold of it.
Hi: not sure if I am missing something, but other than looking at the underlying database, how can I find out the field lengths of string type fields in the rest API?
It would be handy to be able to query this, so fields can be truncated dynamically.
Hi Ted, you are right here, REST API definition does not have information about length. Currently the proper way is to use inspect element function on the field that you need and get the information from PXDBString attribute.
We are working on the Acumatica data structure schema browser and hope it will solve this problem later.
Thanks, thought that might be the case.
The other issue I’m having it trying to decipher / translate between exactly what I see on a screen vs fields in the json. for normal fields not too difficult.
Example:
I am trying to create an invoice using a foreign currency with exchange rate. I figured out the Currency itself is a ‘custom’ field named ‘CuryID’
However, still can’t figure out which field is used to specify the exchange rate. I look on the screen, when customization is selected it does not show a ‘Data Field’ element like most ui controls. I assume because it seems to popup a secondary control? Nothing pops in the schema as obvious.
It would be handy if there was a way to temporarily / easily tell this thing to return all fields / custom fields, related schema. Am I missing something?
Ted, Unfortunately you are right. There is no easy way to find the database schema. As I said, we are working on the schema browser and will provide it later with the product.
Currently I can help you case by case. Rate is stored in the separate table – CurrencyInfo and joined to the document using field CuryInfoID
Hi team,
my requirement is
In stock item screen Get Active vendor details
I use below code
Method : PUT
URL : http://localhost/ACM201030019/entity/KNVendorInventory/18.200.001/StockItem?$expand=VendorDetails&$filter=Active eq ‘true’
Request:
{
“InventoryID”: {
“value”: “AACOMPUT01”
}
}
I am getting below error can you please help me
{
“message”: “An error has occurred.”,
“exceptionMessage”: “Term ‘VendorItems.Active eq ‘true’ ‘ is not valid in a $select or $expand expression.”,
“exceptionType”: “Microsoft.Data.OData.ODataException”,
“stackTrace”: ” at Microsoft.Data.OData.Query.SelectExpandTermParser.ParseSingleSelectTerm(Boolean isInnerTerm)\r\n at Microsoft.Data.OData.Query.SelectExpandTermParser.ParseSelect()\r\n at Microsoft.Data.OData.Query.ODataUriParser.ParseSelectAndExpandImplementation(String select, String expand, IEdmEntityType elementType, IEdmEntitySet entitySet)\r\n at PX.Api.ContractBased.OData.Helpers.ParseSelectCustomAndExpand(ODataUriParser uriParser, String select, String expand, String custom, IEdmEntityType elementType, EntityImpl entity, Nullable`1 returnBehaviorToSet, Boolean mapFilesByDefault)\r\n at PX.Api.ContractBased.OData.Helpers.FillRestQueryOptions(IEdmModel edmModel, EntityImpl entity, String filter, String select, String expand, String custom)\r\n at PX.Api.ContractBased.SystemContracts.V2.RestController.PutEntity(EntityImpl entity, String select, String filter, String expand, String custom)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.c__DisplayClass6_1.b__3(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\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.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.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.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.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.ActionFilterAttribute.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.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.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.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.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.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.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.d__15.MoveNext()”
}
Hey G2,
When you are using a PUT method, the URL should be the high level entity without the filters and clauses.
Try http://localhost/ACM201030019/entity/KNVendorInventory/18.200.001/StockItem instead of http://localhost/ACM201030019/entity/KNVendorInventory/18.200.001/StockItem?$expand=VendorDetails&$filter=Active eq ‘true’
Hey Sergey,
I did like to know if there is a way to create custom entities on the Rest API side of things. For example, is there an option to extend the salesinvoice entity found on the Default endpoint(version 17.200.001) to include a custom field like CustomerType? Also, how about the ability to specify multiple detail entities along with a single header entity?
Thanks,
Hi Lakshman, you can do all of these things in the latest Acumatica. However It may not be possible in 2017 version.
Please read about Endpoint Extensibility.
https://help-2018r1.acumatica.com/(W(1))/Wiki/ShowWiki.aspx?pageid=c450492e-06fe-4563-95c3-efa76975415b
Hi,
I am curious to know more about the fact that ” I can send GET requests without including any authentication or token”. So is my below assumption right?
1. Login using POST Request by sending credentials through BODY.
2. Play with the data- GET, POST, DELETE and PUT requests to get and modify the data
3. LOGOUT using Another request?
Yes, login, than operations, than logout.
But through all these operations you need to keep cookies. Authentication token will be stored in the cookies.
Hi Sergey. There is C#-based REST API client on your official Github account (https://github.com/Acumatica/AcumaticaRESTAPIClientForCSharp).
Would you recommend to use it for real product that integrates with Acumatica or is it mostly for educational purposes?
Aleksandr, this API client is done by my colleague in Partners Support team to make your life easier. Surely you should try to use it. I hope it will save you a lot of time.
Hi Sergey,
I’m trying to use Rest API to create Sales Orders and release them (I have custom action called “ReleaseOrder”, which does some validation checks and if everything is OK just sets SOOrder.Hold checkbox to ‘False’ which sends it to processing flow)
What I found is a huge difference between the time needed to execute Release action in UI, and to execute the same action through REST API. Through the REST API a call runs up to hundreds of secs, while in UI for just a few secs.
Here’s quick number from Request Profiler:
~/entity/edi/6.00.001/soorder/releaseorder/
Server Time, ms: 188,269.89
SQL Time, ms: 3,956.58
What could be the reason for such long execution?
What can I look at to optimize in such cases?
I’m on Acumatica v6.0
I recommend you to create a development support case on Acumatica Portal.
I guess our team need to review your code.
Hey Sergey,
I need to have Accounts and Contacts automatically reach out to a third party api and store the data in attributes when they are loaded. I am finding a ton of information on how to use acumatica’s apis but not alot on how to use third party apis within acumatica. Can you help me out?
Hi Brent, this is not a topic for the blog comments. Please reach out to me in linked it and we can have a call.
I was able to make it work. This is what worked for me.
cd
F:
cd\
cd Tools\curl-7.66.0_2-win64-mingw\curl-7.66.0-win64-mingw\bin
curl -X POST –cookie-jar headers https://XYZnc.acumatica.com/entity/auth/login -d “@F:\EDI Data\Temp\XYZInc\Login.json” -H “Content-Type: application/json”
curl -X GET -b headers “https://XYZnc.acumatica.com/entity/Default/18.200.001/Invoice/Invoice/007878?$expand=Details” -o “F:\EDI Data\Temp\XYZInc\OUT\810\Inv2\201910241734341ED4E027.json”
curl -X POST https://XYZnc.acumatica.com/entity/auth/logout -d “@F:\EDI Data\Temp\XYZInc\Login.json”
cd\
exit
Thanks,
Lakki
Hey Sergey,
I know and have been able to use the Acumatica APIs using Postman. Do you have examples of how to use consume these APIs using cURL? For example, if we were to login, get a salesorder and then logout, I suppose there would be three cURL commands back to back. I was able to come with something like this to be put in a batch script for execution.
cd
F:
cd\
cd TOOLS\curl-7.61.1-win64-mingw\bin
curl -X POST –dump-header headers https://xyz.acumatica.com/entity/auth/login -d “@F:\EDI Data\Temp\XYZInc\Login.json” -H “Accept: */*” -H “Accept-Encoding: gzip, deflate” -H “Cache-Control: no-cache” -H “Connection: keep-alive” -H “Content-Type: application/json” -H “cache-control: no-cache” -o “F:\EDI Data\Temp\XYZInc\OUT\810\Inv2\Login.json”
curl -X GET -b headers -H “Accept: */*” -H “Accept-Encoding: gzip, deflate” -H “Cache-Control: no-cache” -H “Connection: keep-alive” -H “Host: xyz.acumatica.com” -H “cache-control: no-cache” https://xyz.acumatica.com/entity/Default/17.200.001/SalesOrder/3def9dhhgs9845f7af6fe2afc3d9f7b5 -o “F:\EDI Data\Temp\XYZInc\OUT\810\Inv2\AXA.json”
curl -X POST -H “Accept: */*” -H “Accept-Encoding: gzip, deflate” -H “Cache-Control: no-cache” -H “Connection: keep-alive” -H “Content-Type: application/json” -H “cache-control: no-cache” https://xyz.acumatica.com/entity/auth/logout
exit
I could not make it work though. Any pointers?
Thanks
Lakki
I can retrieve records with equal condition using $filter=CustomerName eq ‘vannak’, but I want to retrieve records with condition ‘contain’ and don’t know short key of contain in acumatica rest api. please tell me.
Vannak, please check here – https://help-2019r2.acumatica.com/Help?ScreenId=ShowWiki&pageid=c5e2f36a-0971-4b33-b127-3c3fe14106ff
There are some functions like substringof.
Hi Sergey,
I need to create a Invoice using SOAP api. Do you have any sample or references for the same.
Thanks in Advance,
Vikas
Hi Vikas, please check this training guide, it has a plenty of example including SOAP
https://openuni.acumatica.com/courses/integration/i320-web-services-data-manipulation/
Hi,
I am trying to fetch via Postman all sales invoices with status ‘Open’ for Customer ‘ABC’ with all Details like (Document Details (i.e Item details with Item number quantity, UOM and price), TAX, Billing Address and etc). Even though AdHoc SalesInvoice schema is having Details, BillingAddress details, unable to fetch all details and throws error.
When I use request without “Details in Expand” I am able to fetch Invoice, but response does not have Item level details,
Get – https://www.b2biass.net/acumaticaerp/entity/Default/17.200.001/SalesInvoice?$filter=Status eq ‘Open’ and CustomerID eq ‘AVACUST1’
When I use request with “Details in Expand” as below, I am getting error.
Get – https://www.b2biass.net/acumaticaerp/entity/Default/17.200.001/SalesInvoice?$expand=Details&$filter=Status eq ‘Open’ and CustomerID eq ‘AVACUST1’
Response Error –
{
“message”: “An error has occurred.”,
“exceptionMessage”: “Optimization cannot be performed.The following fields cause the error:\r\nDetails.Amount: View Transactions has BQL delegate\r\nDetails.UnitPrice: View Transactions has BQL delegate\r\nDetails.UOM: View Transactions has BQL delegate\r\nDetails.BranchID: View Transactions has BQL delegate\r\nDetails.Description: View Transactions has BQL delegate\r\nDetails.InventoryID: View Transactions has BQL delegate\r\nDetails.LineNbr: View Transactions has BQL delegate\r\nDetails.OrderNbr: View Transactions has BQL delegate\r\nDetails.OrderType: View Transactions has BQL delegate\r\nDetails.Qty: View Transactions has BQL delegate\r\nDetails.ShipmentNbr: View Transactions has BQL delegate\r\n”,
“exceptionType”: “PX.Api.ContractBased.OptimizedExport.CannotOptimizeException”,
“stackTrace”: ” at PX.Api.ContractBased.OptimizedExport.NotWorkingOptimizedExportProvider.get_CanOptimize() in F:\\Bld\\AC-FULL2018R200-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\OptimizedExport\\NotWorkingOptimizedExportProvider.cs:line 84\r\n at PX.Api.ContractBased.EntityService.GetList(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext, Boolean ignoreValueFields, PXGraph graph) in F:\\Bld\\AC-FULL2018R200-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 116\r\n at PX.Api.ContractBased.Soap.SoapFacadeBase.GetListImpl(Entity entity) in F:\\Bld\\AC-FULL2018R200-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\Soap\\SoapFacadeBase.cs:line 83\r\n at PX.Api.ContractBased.SystemContracts.V2.RestController.GetList(String objectName, String select, String filter, String expand, String custom, Nullable`1 skip, Nullable`1 top) in F:\\Bld\\AC-FULL2018R200-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\SystemContracts\\V2\\RestController.cs:line 247\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.c__DisplayClass10.b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\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.d__0.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.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.Web.Http.Filters.ActionFilterAttribute.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.ActionFilterAttribute.d__0.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.d__2.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.d__2.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.d__0.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.d__0.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.d__1.MoveNext()”
}
Looking forward for someone to suggest how to fetch complete Invoice details. Thanks in Advance
Hi Guna, please check this article: https://help-2019r1.acumatica.com/Help?ScreenId=ShowWiki&pageid=775ca16b-cba6-4c1d-89d5-c1df7833bfea
Note part: “Usage Notes for Endpoints with Contract Version 3”.
To improve database performance, Acumatica optimize select query and remove all details from the select. In case it can’t be done, it will throw the error you have.
So in your case you “$expand=Details” – brings a problem.
You need to retrieve items in 2 steps – get keys from all records first than get record by record using keys.
How would I make a custom endpoint for a generic inquiry where I need to return the view inquiry info?
Hi Adam, you need to create a custom endpoint by extending the default one. There is a button – Extend endpoint.
Than you can add your inquiry to the list of entities. Don’t forget to populate fields.
As soon as that is done, you can use endpoint with PUT method.
Please find more details here: https://openuni.acumatica.com/courses/integration/
I’m having a hard time figuring out the login url. Currently, to get to acumatica from a browser it is “https://mycompany.acumatica.com”. I’ve tried that in postman but I get status 401.
Hi Adam. Acumatica instances usually have different URLs, so you need to figure out url of your Acumatica and use it to login thought web services./entity/auth/login
http://
I figured it out its “https://mycompany.acumatica.com/entity/auth/login”
In exception message
xceptionMessage”: “PX.Data.PXException: Error: ‘Value’ cannot be empty.\r\n —> PX.Data.PXOuterException: Error: Inserting ‘Customer Payment Method Detail’ record raised at least one error. Please review the errors.\r\n at PX.Data.PXUIFieldAttribute.CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)\r\n at PX.Data.PXCache.OnCommandPreparing(String name, Object row, Object value, PXDBOperation operation, Type table, FieldDescription& description)\r\n at PX.Data.PXCache`1.PersistInserted(Object row)\r\n at PX.Data.PXCache`1.Persist(PXDBOperation operation)\r\n at PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation operation)\r\n at PX.Data.PXGraph.Persist()\r\n at PX.Objects.AR.CustomerPaymentMethodMaint.Persist()\r\n at PX.Data.PXSave`1.d__2.MoveNext()\r\n at PX.Data.PXAction`1.d__31.MoveNext()\r\n at PX.Data.PXAction`1.d__31.MoveNext()\r\n at PX.Api.SyImportProcessor.SyStep.a(Object A_0, PXFilterRow[] A_1, PXFilterRow[] A_2)\r\n at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()\r\n
How can I get exact exception message like “nserting ‘Customer Payment Method Detail’ record raised at least one error.”
Hi Maulik,
There is no build in tool for that, but I guess you can use regExp tool to parse it in parts and than combine back. Unfortunately I don’t have a ready solution for that.
yes I checked it but format in ExceptionMessage is always different
yes I checked it but format in ExceptionMessage is always different.
Do you have any idea how I can achieve it?
Hi Maulik,
Unfortunately there is no tool to parse exception i know about. Really sorry about that.
Hi Sergey,
http://localhost/AcumaticaERP/entity/Ourendpoint/17.200.001/CustomerPaymentMethod/
I am trying to add the customer payment method via rest API call but its not working.
{
“CustomerID”: {
“value”: “191396”
},
“PaymentMethod”: {
“value”: “VISA”
},
“CashAccount”: {
“value”: “AUTHNET”
},
“CustomerPaymentMethodDetail” : [
{
“Description” : { “Value” : “Payment Profile ID”},
“Value” : { “Value” : “1542797094”}
},
{
“Description” : { value : “Card Number” },
“Value” : { value : “4111111111111111” },
},
{
“Description” : { value : “Expiration Date” },
“Value” : { value : “10/2025” },
},
{
“Description” : { value : “Card Verification Code” },
“Value” : { value : “555” },
}
]
}
We are getting below error – “PX.Data.PXException: Error: ‘Value’ cannot be empty
Can you please help me out to resolve this error?
xceptionMessage”: “PX.Data.PXException: Error: ‘Value’ cannot be empty.\r\n —> PX.Data.PXOuterException: Error: Inserting ‘Customer Payment Method Detail’ record raised at least one error. Please review the errors.\r\n at PX.Data.PXUIFieldAttribute.CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)\r\n at PX.Data.PXCache.OnCommandPreparing(String name, Object row, Object value, PXDBOperation operation, Type table, FieldDescription& description)\r\n at PX.Data.PXCache`1.PersistInserted(Object row)\r\n at PX.Data.PXCache`1.Persist(PXDBOperation operation)\r\n at PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation operation)\r\n at PX.Data.PXGraph.Persist()\r\n at PX.Objects.AR.CustomerPaymentMethodMaint.Persist()\r\n at PX.Data.PXSave`1.d__2.MoveNext()\r\n at PX.Data.PXAction`1.d__31.MoveNext()\r\n at PX.Data.PXAction`1.d__31.MoveNext()\r\n at PX.Api.SyImportProcessor.SyStep.a(Object A_0, PXFilterRow[] A_1, PXFilterRow[] A_2)\r\n at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()\r\n
How to post shipment and Invoice using API through Postman?
Hi Dafza,
I recommend you to check Acumatica Integration training. There is an example of shipment creation. Invoice will be a second call but almost the same:
https://openuni.acumatica.com/courses/integration/i320-web-services-data-manipulation/
I made an update on the sales order, but only the header that was updated did not go to the grid line ..?
the method I use at the postman is put for update ..?
Hi Dafza,
Put is correct for update. Please note that to update grid records, you need to specify key of the record. I recommend you to use ID for that. So assign ID (guid) and send it back using Put method.
how to get an invoice inventory id, I always error while the sales order does not
Eror List : “message”: “An error has occurred.”,
“exceptionMessage”: “The given key was not present in the dictionary.”,
“exceptionType”: “System.Collections.Generic.KeyNotFoundException”,
“stackTrace”: ” at System.ThrowHelper.ThrowKeyNotFoundException()\r\n at System.Collections.Generic.Dictionary`2.get_Item(TKey key)\r\n at Microsoft.Data.OData.Query.SyntacticAst.ExpandBinder.GenerateExpandItem(ExpandTermToken tokenIn)\r\n at System.Linq.Enumerable
From the error message it looks like you provide a key that does not present in the system./entity/////key2
please note url should be: https://
Hi Sergey,
I am trying to access the attributes defined Attribute Tab from the Projects (PM301000) from the Sales Order Request. Though in the sale sorder schema I could see only project Tasks. I also tried the Customization tab to see the Data View and Data Field but i am not able to determine the entity from the same.
Snippet from the Sales Order
“OvershipThreshold”: {},
“POSource”: {},
“ProjectTask”: {},
“PurchasingSettings”: {
“id”: “3f6011db-3a92-4267-9589-2793ff47917c”,
“rowNumber”: 1,
“note”: null,
“POSiteID”: {},
“POSource”: {},
“VendorID”: {},
“custom”: {
“currentposupply”: {
“NoteID”: {
“type”: “CustomGuidField”,
“value”: null
}
}
},
“files”: []
},
Thanks
Reema
I just checked for this form PM301000 the web service endpoint is not defined in Default endpoint. I will define this and check if it helps
Hi Reema,
Unfortunately you cant get project attributes directly from PO, only fields available in UI are available in API.
So you need to select projects separately. If projects are not available in default endpoint, please extend it and add projects screen there.
Hi Sergey
Do you have a working JSON example for creating a supplier. It’s the payment method that’s causing me an issue as it looks like it needs to be in an array.
Also if I may, is there any way of batching a request with the rest api? I want to load a few thousand customers and would rather batch a request rather than do it one at a time else I’ll be waiting for a while.
Thanks
Hi Steven,
Can you show me your supplier JSON and error and I’ll try to help.
Related to batch update – it is not supported in Rest unfortunately. However is you use Screen Based SOAP Api, than you can do batch upload using Import(…) method.
Hi Sergey
Do you know how much faster the SOAP API is for loading data? Is the REST API ever going to be upgraded to handle batch requests?
The JSON is:
{“VendorID”:{“value”:”50″},”VendorName”:{“value”:”XXX Pty Ltd”},”TaxRegistrationID”:{“value”:”99 009 254 888″},”TaxZone”:{“value”:”DOMESTIC”},”AccountRef”:{“value”:”XXCO”},”CashAccount”:{“value”:”100010″},”RemittanceAddressSameasMain”:{“value”:true},”ShippingAddressSameasMain”:{“value”:true},”LocationName”:{“value”:”Main Location”},”LocationID”:{“value”:”Main”},”PaymentMethod”:{“value”:”AUWBCDC”},”MainContact”:{“Email”:{“value”:”test@test.com”},”Phone1″:{“value”:”01 9444 8066″},”Phone2″:{“value”:””},”Fax”:{“value”:”01 9444 4121″},”WebSite”:{“value”:””},”Address”:{“AddressLine1”:{“value”:”PO Box 50″},”AddressLine2″:{“value”:””},”City”:{“value”:”Mount Hawthorn”},”State”:{“value”:”WA”},”PostalCode”:{“value”:”6935″}}},”RemittanceContact”:{“Email”:{“value”:”test@test.com”},”WebSite”:{“value”:””},”Phone1″:{“value”:”01 9444 2222″},”Phone2″:{“value”:””},”Fax”:{“value”:”01 9444 4444″},”Address”:{“AddressLine1”:{“value”:”PO Box 90″},”AddressLine2″:{“value”:””},”City”:{“value”:”Mount Hawthorn”},”State”:{“value”:”WA”},”PostalCode”:{“value”:”6980″}}},”ShippingContact”:{“WebSite”:{“value”:””},”Phone1″:{“value”:””},”Phone2″:{“value”:””},”Fax”:{“value”:””},”Address”:{“AddressLine1”:{“value”:”Unit 3 / 63 Walters Drive”},”AddressLine2″:{“value”:””},”City”:{“value”:”Osborne Park”},”State”:{“value”:”WA”},”PostalCode”:{“value”:”6017″}}},”PaymentInstructions”:[{“ID”:{“value”:”Account Number”},”Value”:{“value”:”121213134″}},{“ID”:{“value”:”Title of Account”},”Value”:{“value”:”XXX”}},{“ID”:{“value”:”BSB Number”},”Value”:{“value”:”111-222″}}]}
The Error message is:
{
“message”: “An error has occurred.”,
“exceptionMessage”: “PX.Data.PXException: Error: The system failed to commit the PaymentDetails row.\r\n at PX.Api.SyImportProcessor.SyStep.CommitChangesInt(Object itemToBypass, PXFilterRow[] targetConditions, PXFilterRow[] filtersForAction)\r\n at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()”,
“exceptionType”: “PX.Api.ContractBased.OutcomeEntityHasErrorsException”,
“stackTrace”: ” at System.Monads.ArgumentCheck.CheckNull[TSource](TSource source, Func`1 exceptionSource)\r\n at PX.Api.ContractBased.EntityService.GetOperationResult(EntityImpl entity, EntityExportContextBuilder entityExportContextBuilder, PXSYTable exportedKeys, List`1 errors)\r\n at PX.Api.ContractBased.EntityService.Put(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext)\r\n at PX.Api.ContractBased.Soap.SoapFacadeBase.PutImpl(EntityImpl entity)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.c__DisplayClass10.b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\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.d__0.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.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.Web.Http.Filters.ActionFilterAttribute.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.ActionFilterAttribute.d__0.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.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.Web.Http.Filters.ActionFilterAttribute.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.ActionFilterAttribute.d__0.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.d__2.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.d__2.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.d__0.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.d__0.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.d__1.MoveNext()”
}
Thanks for all your help.
Hi Steven,
I have checked this, but unfortunately cannot find issues from the high level look. PaymentInstructions is a special grid that may need to have a special code support in Acumatica. I guess we need to do a bit of investigations and may be debugging. Could you please create a case for that?
Related to batch upload via rest – I haven’t seen this feature in 2 years roadmap.
Related to performance – batch upload may be a bit faster due to time savings on communication. But in general performance on single records should be the same.
Hi Sergey,
Thank you for the sharing the url.
I am able to successfully sync the customer. I would like to sync the Order with Rest PHP curl.
Could you please guide me?
Vishves,
Please use T410 training course that will explain you how to use Acumatica REST API.
https://openuni.acumatica.com/courses/development/t410-customization-of-mobile-application-advanced/
It also contains some examples.
Thank you, Sergey!
I will check the training course and get back to you.
Thank you again!
Hello Sergey,
I want to sync our order data to our Acumatica ERP.
Also, I found some difficulty for adding the field to Acumatica endpoint, Can you please guide?
Can you please guide me how can I sync order data to the AcumaticaERP with PHP CURL.
Help will be appreciated!
Thanks,
Vishves Shah
Hi Vishves
Please check this article, it seems that it is doing the same: https://www.timrodman.com/acumatica-rest-api-php-curl/
Hi all can you help me?
I need to export Ap bills with details.
When I use Bill entity everthing ok. buy I got error when I tried to use Detail etity by expand param.
my url is : http://34.217.248.140/WSA2018R1/entity/Default/17.200.001/Bill?$expand=Details
error: “message”:”An error has occurred.”,”exceptionMessage”:”Optimization cannot be performed.The following fields cause the error:\r\nDetails.Account: View Transactions has BQL delegate\r\nDetails.ProjectTask: View Transactions has BQL delegate\r\nDetails.Qty: View Transactions has BQL delegate\r\nDetails.Subaccount: View Transactions has BQL delegate\r\nDetails.TaxCategory: View Transactions has BQL delegate\r\nDetails.TransactionDescription: View Transactions has BQL delegate\r\nDetails.UnitCost: View Transactions has BQL delegate\r\nDetails.UOM: View Transactions has BQL delegate\r\nDetails.Amount: View Transactions has BQL delegate\r\nDetails.Branch: View Transactions has BQL delegate\r\nDetails.Description: View Transactions has BQL delegate\r\nDetails.ExtendedCost: View Transactions has BQL delegate\r\nDetails.NonBillable: View Transactions has BQL delegate\r\nDetails.POOrderNbr: View Transactions has BQL delegate\r\nDetails.POOrderType: View Transactions has BQL delegate\r\nDetails.Project: View Transactions has BQL delegate\r\n”,”exceptionType”:”PX.Api.ContractBased.OptimizedExport.CannotOptimizeException”,”stackTrace”:” at PX.Api.ContractBased.Optimize.
Please advice what is wrong andd how can I manage this? to get details
every help will be appreciated
Hi Tatevik,
You should do this with several requests:
– Call for keys only for all bills you need. This is in bulk in one request.
– Than retrieve records by keys. This is one by one.
Unfortunately you can’t get details in bulk with headers due to performance impact it is blocked.
thank you for your reply but if key field is not present in the detail entity should I expand old Entity and add it?
For bill keys will be DocType and RefNbr – these are keys of the parent entity (Bill itself)
So when you get document by keys, you can get details.
Hi,
I want to attach a file to sales order line items using web service end point. What should be the endpoint for same?
Hi Anshu,
Please check this article: https://asiablog.acumatica.com/2018/01/attach-files-with-rest-api.html
Hi Sergey,
I have checked the link provided by you. I want to attach a file to sales order Details line item. For that what endpoint should i use?
Like i have detail item with Inventory Id as P123. I want to attach a file to this line item. How should i generate the endpoint for adding a file to line item?
Hi Anshu, I’m really sorry, but attach file to details can be done only in Screen Based API for now. We might improve it later, but for now it is not possible.
I need to access the Shipping Address from Sales Order. I am able to use the $custom query parameter and my query looks like this:
https:///entity/Default/17.200.001/SalesOrder?$filter=OrderNbr eq ‘029623’&$expand=Details&$custom=Shipping_Address.AddressLine1,Shipping_Address.AddressLine2,Shipping_Address.City,Shipping_Address.CountryID,Shipping_Address.State,Shipping_Address.PostalCode
However the query looks very busy, could there be another way to get the Shipping Address from Sales order?
Moreover, in the $Adhoc Schema for SalesOrder I could see the ShipToAddress field as
—————
“ShipToAddress”: {
“id”: “541b64e2-22dc-4cfe-b3a4-a83c84e1a300”,
“rowNumber”: 1,
“note”: null,
“AddressLine1”: {},
“AddressLine2”: {},
“City”: {},
“Country”: {},
“PostalCode”: {},
“State”: {},
“custom”: {},
“files”: []
},
—————
But when I retrieve the SO then ShipToAddress is not retrieved. How can I access this element and avoid the custom queries.
Hi Reema,/entity/Default/17.200.001/SalesOrder/SO/029623$expand=ShipToAddress
Could you please try this way?
https://
I’m trying to create a Customer using the REST API. I’ve extended the default endpoint and added 2 fields that are required but when posting, it created an Address record with a BAccountID -2147483647 and didn’t create the Customer.
The JSON I’m using:
{
“CustomerID”: {
“value”: “TEST8945129A5”
},
“CustomerName”: {
“value”: “TEST CUSTOMERR”
},
“CustomerClass”: {
“value”: “01”
},
“StatementCycleId”: {
“value”: “01”
},
“ShippingAddressSameAsMain”: {
“value”: true
},
“Status”: {
“value”: true
},
“ParentRecord”: {
“value”: null
},
“MainContact”: {
“DisplayName”: {
“value”: “TEST CUSTOMERR”
},
“Email”: {
“value”: “a@b.com”
},
“Address”: {
“AddressLine1”: {
“value”: “Test test test”
},
“AddressLine2”: {
“value”: “Test test test”
},
“City”: {
“value”: “Monterrey”
},
“State”: {
“value”: “NL”
},
“PostalCode”: {
“value”: “00300”
},
“Country”: {
“value”: “MX”
}
}
},
“BillingContact”: {
“CashAccount”: {
“value”: “BANAMEXMN”
},
“CardAccountNo”: {
“value”: “0000000000”
}
}
}
Using PUT to the URL: my.site/AcumaticaSQL/entity/DefaultCustomer/17.200.001/Customer
From the first look your script looks OK. But if there is a record create with negative id, it looks like an internal problem.
I recommend you to use Request Profiller and try to get an internal errors (if any) from there. I guess there is something that is not displayed.
https://asiablog.acumatica.com/2015/11/using-acumatica-first-chance-exception.html
Hi Reema,
You need to specify each custom field one by one how it is shown here: https://help-2018r2.acumatica.com/(W(2))/Help?ScreenId=ShowWiki&pageid=c5e2f36a-0971-4b33-b127-3c3fe14106ff
Also note that you can retrieve schema of custom field as it show here: https://help-2018r2.acumatica.com/(W(2))/Help?ScreenId=ShowWiki&pageid=c5e2f36a-0971-4b33-b127-3c3fe14106ff
In your query you should remove brackets “(” and “)” . Other fields should be specified just as a comma “,” separated string:
?$expand=Orders,Details,Packages$custom=CurrentDocument.LoadNbr,CurrentDocument.OtherNbr,
Thanks Sergey! 🙂
I am able to retrieve a custom field in Sales Order using the following request URL:
https:///entity/Default/17.200.001/SalesOrder?$filter=OrderNbr eq ‘029623’&$custom=CurrentDocument.LoadNbr
Also, the same Sales Order is part of the Shipment:
https:///entity/Default/17.200.001/Shipment/022006?$expand=Orders,Details,Packages
The above request will expand Order as the particular Sales Order as :
“Orders”: [
{
“id”: “cc5bb9b7-b66d-439b-90b1-cb8bfa336c76”,
“rowNumber”: 1,
“note”: “”,
“InventoryDocType”: {
“value”: “Issue”
},
“InventoryRefNbr”: {
“value”: “057792”
},
“InvoiceNbr”: {},
“InvoiceType”: {},
“OrderNbr”: {
“value”: “029623”
},
“OrderType”: {
“value”: “SO”
},
“ShipmentNbr”: {
“value”: “022006”
},
“ShipmentType”: {
“value”: “Shipment”
},
“ShippedQty”: {
“value”: 25
},
“ShippedVolume”: {
“value”: 0
},
“ShippedWeight”: {
“value”: 0
},
“custom”: {},
“files”: []
}
Is it possible to retrieve the custom field or all custom fields of Sales Order from the Shipment request such as
https:///entity/Default/17.200.001/Shipment/022006?$expand=Orders($custom=CurrentDocument.LoadNbr),Details,Packages
The above request is failing for me though. The requirement is to retrieve all details of Sales Order from GET Shipment endpoint.
Hello,
I am looking to create a customer using the REST API and have not been successful. Can someone share the payload or article they are using to create a customer?
I found the problem that was causing my issues with creating a customer, the endpoint is case sensitive. I was submitting to /entity/default/18.200.001/customer where I should be submitting to this /entity/Default/18.200.001/Customer.
How to find entity version of end point webservice in CB based REST API?
Hello Sanpro,
As an administrator search ‘Web Service Endpoints’ in Acumatica. When you are on the screen select which endpoint you are looking for. As an Example ‘Customer’. In the summary top area, you can select the magnify glass and see all the support versions. Here is an active endpoint /entity/default/18.200.001/customer.
I want to create REST API but i did not getting webservices for contract based REST API can you help me regarding this?
Hi Sanpro, go to Acumatica, open Web Services Endpoint, select default.
Than use use button “View Endpoint Service” and then OpenAPI 2.0. This is definition for REST API you can consume in 3rd party product.
I am not getting webservice end point in acumatica .Please explain how to find those webservice end point
Hello Sergey,
My confusion is that we have 3 tenants and the same companies exist in all the tenants. Is there some special code I need to reference in the API call to make sure that the correct tenant and company is used.
Hi Derek, I think confusion here comes from naming. Company in this login refers Tenant. This is old naming that we had in the past. So when you choose Company you actually choose tenant. Branch will be the name of company or branch.
Hope it clarifies.
Perfect, that clarifies a lot.
Hey Sergey,
I have 3 tenants in one instance and I am using the rest API. I am trying to figure out how we can pass the tenantid in the login endpoint. /entity/auth/login.
The call looks to be defaulted to the first tenant that we created .
1. Demo
2. Pre-Live
3. Live
Any ideas?
Hi Derek,
Please send there the JSON like this:
{
“name” : “admin”,
“password” : “123”,
“company” : “MyStore”,
“branch” : “MYSTORE”
}
Hi Sergey,
Is there a way to create new rest API endpoint without specify Screen ID?
We have an extension DAC (xxCompany) of Company. We’d like to insert/update xxCompany through API without creating new or update existing screen.
Thanks.
Hi Vo,
Unfortunately no. The reason is that only Graph knows how to properly save the data and graph is 1to1 linked with page. Plus Acumatica gets sequence of data import from screen.
So currently Graph and Page are mandatory for entities in the endpoint.
Im trying to access the field of object in Web Service Endpoint using another object, is that possible ?
Hi Leomil. What do you mean under other object? Does it means that you want to get Customer Email using Sales Orders entity?
If yes, than it is not possible. All fields are linked to particular screens and can be accessed only from there.
For example I have an API, in that API I want to get the customer email and sales order using one API
Hi Sergey,
{
“entity” : [record in JSON format],
“parameters” : [parameters in JSON format]
}
Can you please give an example for passing the entity. I am getting an error like this:
{
“message”: “The request is invalid.”,
“modelState”: {
“entity”: [
“Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path ‘entity’, line 2, position 13.”,
“The Entity field is required.”
],
“parameters”: [
“Error reading JObject from JsonReader. Current JsonReader item is not an object: Null. Path ‘parameters’, line 119, position 23.”
]
}
}
Pravallika,
Could you please post here your request? JSON object is fine. What are you sending to Acumatica?
I’m trying to retrieve all of the Taxes like this:
var tax = new Tax { ReturnBehavior = ReturnBehavior.All };
_client.GetList(tax);
But I’m getting this error:
PX.Api.ContractBased.OptimizedExport.CannotOptimizeException: More than one detail properties have been used in the request:
TaxSchedule
Zones
Only one of the detail properties of each entity can be requested at once
I need the TaxSchedule detail property polulated, I will not be using the Zones property. So how can I request the Tax and TaxSchedule?
Spoke too soon, I just discovered the XXReturn classes. All is good!
I have performed these steps:
1. Created an adhoc SQL query and published it to the Acumatica server as a view.
2. Created a DAC and Generic Inquiry from that published view. It returns data.
3. Created a Contract 3 Web Service Endpoint.
4. Tested the endpoint from Postman. I can get a response for the $adHocSchema GET request. I get a single record response back if I use a PUT and use any parameter. getList() throws an error: “PX.Api.ContractBased.OptimizedExport.CannotOptimizeException”
The GI returns many records. Postman REST PUT test returns one record. Why? I have added IsKey to all of the foreign fields in the DAC.
Hi Tim,
Try to use Put method where you get only one row and than add Expand parameter like here:
http://acusea.acumatica.com/entity/Test/18.200.001/CashOutlay?$expand=Result
This should work.
I have created a new form through customization, how can I fetch / push data through rest endpoints for the custom fields?
Hi Reema,
Yes API is available for custom forms either. You just need to add this form to your endpoint.
Please refer to the I210 training guide where you can find how to extend an endpoint with new custom form
https://openuni.acumatica.com/courses/integration/i210-contract-based-web-services/
Example 1.1.1: Extending the System Endpoint
Hi,
For a particular Sales Order, I am trying to create a shipment, confirm shipments and process invoices through REST Endpoints. For Processing an Invoice , I am using the following endpoint :
POST https://www.b2biass.net/acumaticaerp/entity/Default/17.200.001/SalesOrder/PrepareSalesInvoice.
In this step, the invoice is created in AcumaticaERP but the response is empty with a 202 Accepted status(in Postman). Is there a way to retrieve the newly generated invoice reference number from this request.
Hi Reema,
When you release invoice you get back the ID. Use this Id to get record back later. Also monitor the status to get confirmation that record is processed.
Please see example here : https://help.acumatica.com/(W(3))/Help?ScreenId=ShowWiki&pageid=91bf9106-062a-47a8-be1f-b48517a54324
Hi, How can I update the items on a sales order record through REST API, such as the quantity, discount? do I need to supply a specific row number? If i’m trying to update its creating a new line but that’s not i need, it should be update based on inventory id. please help me out.
Hi Munesware,
Please check I210 training guide: https://openuni.acumatica.com/courses/integration/i210-contract-based-web-services/
User “id” property to specify line key. You can select it first, than use it.
entityAsString = JsonConvert.SerializeObject(new
{
OrderType = new { value = orderType },
OrderNbr = new { value = salesOrderNbr },
Details = new[]
{
new {
id = detailLineId,
Quantity = new { value = secondItemQuantity} }
}
});
Hi Sergey Marenich
Thanks Its working fine, can we check specific item is there or not in the Sales order using filter operation, because its not easy to fetch the item id in the salesorder to update it.
i tried with /SalesOrder?$expand=Details&$filter=ExternalRef eq ‘3422978000000217039’&$filter=Array.Details.InventoryID eq ‘DEMOITEM4’
Hi Munesware,
Checking item by InventoryId is not always correct as you may have multiple lines with the same inventory item in the SO.
Better use IDs, or select items with filtering by Inventory and than get IDs
I didn’t get the point “select items with filtering by Inventory and than get IDs” can you give me the example to fetch the ID
Hi Munesware,
Please refer to I210 training guide: https://openuni.acumatica.com/courses/integration/i210-contract-based-web-services/
string searchParameters = “$filter=CustomerOrder eq ‘” + customerOrder + “‘&$filter=OrderType eq ” + orderType + “&$expand=Details”;
string salesOrderToBeUpdated = rs.Get(“SalesOrder”, searchParameters);(salesOrderToBeUpdated)[0][“OrderNbr”].value;>(salesOrderToBeUpdated)[0];(“Details”);
string salesOrderNbr = JsonConvert.DeserializeObject
JObject jSalesOrder = JsonConvert.DeserializeObject
JArray orderLines = jSalesOrder.Value
string detailLineId = null;(“value”); (“value”);
foreach (JObject orderLine in orderLines)
{
string inventoryId = orderLine.GetValue(“InventoryID”).Value
string warehouseId = orderLine.GetValue(“WarehouseID”).Value
if (inventoryId == firstItemInventoryID && warehouseId == firstItemWarehouse)
{
detailLineId = orderLine.GetValue(“id”).ToString();
break;
}
}
H Sergey,
I try to get list of tenants per site.
[GET] http://localhost:5481/entity/Security/17.200.001/Tenants (SM203530)
It gives me error. Please assist.
“exceptionMessage”: “Optimization cannot be performed.The following fields cause the error:\r\nTenantName: View Companies has BQL delegate\r\nTenantID: View Companies has BQL delegate\r\nCurrent: View Companies has BQL delegate\r\nLoginName: View Companies has BQL delegate\r\nStatus: View Companies has BQL delegate\r\n”,
“exceptionType”: “PX.Api.ContractBased.OptimizedExport.CannotOptimizeException”
however, if I try to put in CompanyID, it returns expected data.
[GET] http://localhost:5481/entity/Security/17.200.001/Tenants/3
Hi Vo,
This is introduces in 3rd version Contract API. Please read here https://help.acumatica.com/(W(1))/Help?ScreenId=ShowWiki&pageid=2f1bcceb-fcf6-4e92-a85c-50cc8166612b
Search for “optimization fails”.
I try to create execution action endpoint for Certificate Replacement (SM200535). It returns 202 (accepted).
However instead of replacing new certificate, Acumatica reset to default certificate which is empty current certificate.
Here is my endpoint detail
http://localhost:5481/entity/Security/17.200.001/CertificateReplacement/ProcessAll
Body
{
“entity” : {
“PendingCertificate” : {
“value”: “khiem_data_security”
}
}
}
Hi Vo,
Unfortunately I can’t answer this from top of my head and need to debug code first. I’ll try to do this as soon as I have some time. But it may be faster if you create a supprot case, so our services team can check your code faster.
Hi Sergey,
I have created a new REST API endpoint. Now, I want to deploy it to 200 sites of my clients. How can I achieve that?
There was a post from Acumatica stackoverflow said that the API migration can be done through customization package. However, in my situation it is very troublesome to manually apply customization for 200 sites.
Best Regards,
Khiem.
Hi Vo, this is correct that you need to use Customization Packages. But to automate publications on 200 sites, you can use the special services for customization maintenance.
Please read about it here: https://asiablog.acumatica.com/2016/07/publish-customization-through-web.html
I create an endpoint for SM200530 and try to upload attachment file through rest API. Please note that DAC of this screen does not have CD column. Therefore the uri of api as below.
(PUT) http://localhost:5481/entity/Security/17.200.001/EncryptionCertificate/e8e1d3c5-f9fd-49d9-9afc-b209d4f9522d/files/test.txt
(BODY) binary -> attached test.txt file
Error from postman
{
“message”: “An error has occurred.”,
“exceptionMessage”: “No entity satisfies the condition.”,
“exceptionType”: “PX.Api.ContractBased.NoEntitySatisfiesTheConditionException”,
“stackTrace”: ” at PX.Api.ContractBased.EntityService.PutFiles(ISystemContract systemContract, String version, String name, EntityImpl entity, File[] files, CbOperationContext operationContext)\r\n at PX.Api.ContractBased.SystemContracts.V2.SoapFacade.PX.Api.ContractBased.IRestGate.PutFile(EntityImpl entityImpl, String filename, HttpContent body)\r\n at PX.Api.ContractBased.SystemContracts.V2.RestController.PutFile(String objectName, String ids)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.c__DisplayClass10.b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\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.d__0.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.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.Web.Http.Filters.ActionFilterAttribute.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.ActionFilterAttribute.d__0.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.d__2.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.d__2.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.d__0.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.d__0.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.d__1.MoveNext()”
}
I figured out myself. I passed the wrong key.
This is the correct uri
http://localhost:5481/entity/Security/17.200.001/EncryptionCertificate/Test 02/files/test.txt
How to post sales order using API through Postman?
Hi Gargi,
Please check this post: https://stackoverflow.com/questions/42849722/acumatica-rest-api-to-get-sales-order-with-line-item-detail
Hey Sergey,
I am trying to find if there is a problem with the REST API endpoints starting with 6.00.001. This has been happening for the past couple of days. The usual SalesOrder endpoint I have been using in the past is now rendering a “Object reference not set to an instance of an object”. Any clues why this is happening?
Thanks
Lakki
Hi Lakki, as far as I know there are many customers who are using REST API 6.00.
And NullReferenceException may be a reason of many things including Sales Order itself.
Could you please provide a bit more details? – Stack Trace, code?
Hi Sergey,
When sending a request fetch details for a specific StockItem is it possible for the response to include information on the ItemSalesCategory records a item is associated with?
I reviewed the StockItem schema, but was unable to locate a reference to the associated ItemSalesCategory fields.
I did find a method to retrieve the information by making a second request using a filter on ItemSalesCategory, but it would help reduce the number of calls required to integrate each StockItem if there was a method to include these details with the existing information for a StockItem.
Nick, sorry for later reply.
You can retrieve data by using record ID. Read about it here http://help.acumatica.com/Main?ScreenId=ShowWiki&pageid=bc9531b0-717b-4b2d-8899-ff7ca805ade1
Or you also can retrive and update record by keys
http://help.acumatica.com/Main?ScreenId=ShowWiki&pageid=52c97a83-1fa1-40e9-8219-52a89a91f2da
Id can be obtained from "ID" field when you retrieve records.
To contact me please message me in linkedin or thought google hangouts. For security reasons I do not want to publish my skype on blog.
HI Sergey,
The InventoryID does not work either.
I am trying to update the shipping lines (Lot Serial Numbers) via a put method, but it seems that the api method only attempts to add new line. is there some kind of identifier (like the @@ in import scenarios) so I can uniquely identify a specific shipping line.
What would be the best way to message you, so I can give you my skype info?
Thanks for all the help.
Nick,
One of the issues you have is "Inventory" -it should be "InventoryID"
But if that does not help, please connect me by skype and we can discuss it there. I'll need an error message.
Hi Sergey,
I was referring to how use the rest api. I am using postman and I have been unable to submit a value to the detail array.
I was thinking it would look something like this:
{
ShipmentNbr: { value: "Shipment #" },
ShipmentDate: { value: "4/26/2018"},
Detail: [
{
Inventory: { value: "Some Item ID"},
ShippedQty: { value: "9" }
}
]
}
This does not seem to work.
Thanks in advance
Hi Nick,
You can use allocations popup on SO to put LotSerialNbr there:
new SalesOrderDetail()
{
InventoryID = new StringValue() { Value = "AAMACHINE1" },
Allocations = new SalesOrderDetailAllocation[]
{
new SalesOrderDetailAllocation()
{
Allocated = new BooleanValue() { Value = true },
LotSerNbr = new StringValue() { Value = "123" },
},
},
Or you can create shipment from shipment screen and link it with sales order. In second case you need to have 2 calls.
Hi, How can I update the lines on a Shipment, such as the LotSerialNumber? do I need to supply a specific row number?
Hey Tourvi,
You should be able to get the list of available endpoints and its fields on the menu "System" >> "Integration" >> "Web Service Endpoints".
Goodluck!
Hi, where can I find a list of all the top-level entities that can be retrieved through the api?
Thanks
Hi Maurício,
I'm really sorry for long reply. Could you please create a case with Acumatica team? It looks that we need to investigate your problem. Thank you!
Thanks for the response Sergey …
I tried passing the OrderType as well. I tried using ProductionNbr as well as the DB field name ProdOrdID. The Action is defined in the web services endpoint ProductionOrder > Actions > ReleaseProductionOrder.
Passing the number and type my response was:
{
"message": "The request is invalid.",
"modelState": {
"parameters": [
"Error reading JObject from JsonReader. Current JsonReader item is not an object: Null. Path 'parameters', line 3, position 22."
]
}
}
Thanks a lot,
Mauricio
Hi Maurício,
I see that you miss the second key of Production Order – OrderType. When you pass entity you need to pass all keys to find it.
Also make sure that your action is defined in the contract.
Hello,
I created a Production Order using the REST api in Postman. Now I need to release this production order.
I am POSTing to http://localhost/Development/entity/MANUFACTURING/17.200.001/ProductionOrder/ReleaseProductionOrder
{
"entity":{"ProductionNbr": {"value": "0000249"}},
"parameters": null
}
response:
{
"message": "The request is invalid.",
"modelState": {
"parameters": [
"Error reading JObject from JsonReader. Current JsonReader item is not an object: Null. Path 'parameters', line 3, position 22."
]
}
}
Any idea on why I am getting this message ?
Thanks,
Mauricio Camara
Hi Rajasekaran,
I do not think you can do this in one request. I suggest you get oldest receipt from receipts screen or generic inquiries and than create a adjustment with second request.
Hi, how do I select a value from a selector based on some condition? I'm creating an Inventory Adjustment transaction and I need to select a ReceiptNbr to associate with the adjustment transaction. I need to select the oldest receipt with a non zero qty. on hand from the selector. How do I perform this? Can you provide an example? Thank you.
-Raj
NonStockItem or StockItem are not the best place for price, as price may be different per customer/class/item/promotion and so on.
There is an example in our Acumatica I210 training guide (Contract-Based Web Serivices) that uses small csutomization fro that. Please check Lesson 3.4: Retrieving the Price of an Item
You can do the same with REST, but use PUT method
I did think the best way to fetch a product price would be to use the endpoint for products(NonStockItem or StockItem I think) and then use the response JSON to extract the relevant information (in this case the price as you want it) from it.
As for the multiple addresses, I think these multiple addresses would need to be added as a JSON array onto the corresponding linked entity. I have not tried it myself though.
Cheers
Hi,
One more thing, can you please tell me how to fetch product price through API and add multiple addresses to a customer in POST request.
Regards,
Saha
Hi Lakki,
Thank you, that worked.
Regards,
Saha
Hi Indranil,
Try using no filters to find out the date field name for the specific object(endpoint) you are looking for. For example, the StockItem endpoint gives information about the items that are on stock. It has a field 'LastModified' that accepts date values as filters. Here is how the filter can be applied.
https:///StockItem?$filter=ItemStatus eq 'Active' and LastModified gt datetimeoffset'2017-10-01'
This URI would fetch all stock items that are in a status of 'Active' and modified after 01-OCT-2017.
Good luck.
Hi,
Can you tell me how to use date filter while fetching items. The filter mentioned in the documentation doesn't seem to work.
Regards,
Indranil Saha
Hi Sergey,
Thank you for the reply.
Regards
Lakki
Vannak,
Yes, you can but you need to put custom fields in a special collection.
Please check here: https://help.acumatica.com/(W(5))/Main?ScreenId=ShowWiki&pageid=64daacf1-75c4-4bfa-b57b-36222020e7c9
Can we create record with custom field in rest api:
{
"OrderType": {value: "IN"},
"CustomerID" : {value : "1ARA" } ,
"Details" :[
{
"InventoryIDz": {value: "1BRO01"},
"InventoryID" : {value: "6DOC"}
}]
}
Hi Lakki,
Try https://acusea.acumatica.com/entity/Default/6.00.001/SalesOrder?$expand=Details
Expand should add details records to result. In Expand you should pass name of container that exists in Acumatica Contract Endpoint.
But please note that it will significantly affect performance
Hi Sergey,
Could you give an example of how the expand parameter can be used?
I tried the following but it did not work.
http://try.acumatica.com/isv/(W(4))/entity/Default/6.00.001/SalesOrder?$expand=SalesOrderDetail
Benjamin,
Thank you for confirmation. Ans sorry fore late replay, that is due to time-zones.
Hi Sergey,
Nevermind on this. I was able to get it to work.
I needed to add the PrepareInvoice action in web service endpoint SalesOrder.
Hi Sergey,
I am trying to use the action Prepare Invoice for a sales order with the instructions from your post dating 26th January.
I can't get it to work, do you think it is possible to do it for this action ?
Thanks,
Tim,
Thank you for confirmation!
Hi Sergey,
Nevermind on this. I was able to get it to work.
I just had to figure out how to pass cookies between the requests. I couldn't figure out though how to post my successful PHP code sample here in the comments so I created a post on my blog instead.
You can go here for the successful PHP code that I used:
http://www.TimRodman.com/acumatica-rest-api-php-curl/
Hi Sergey,
I'm trying to work with the REST APIs using PHP cURL code.
I'm testing by doing to calls in Postman: Login, Create a Customer. It works fine.
Then I generate the PHP cURL code and run the code in PHP, but I get an error on the second call: {"message":"You are not logged in."}
I'm thinking that Postman automatically passes the session information between calls.
So, I added Postman Interceptor and now I get back cookie information like this: https://imgur.com/a/zejPA
But, when I generate the PHP cURL code, it still doesn't generate the cookie information:
"http://localhost/Acumatica/entity/auth/login",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{rn "name": "admin",rn "password": "mypassword",rn "company": "Company"rn}",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/json",
"postman-token: 3af0af99-e514-ab2e-4f69-7481a1b9c6ce"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Do you know how to get the PHP cURL code that will pass the cookie information between API calls?
Hi Dkardell,
You should pass filters with query URL. And yes, you should have spaces there, but in the end spaces should be encoded as accordingly to standard URL encoding rules
How do you pass the filter? Your example has spaces in it?
http://acumatica.com/entity/Default/6.00.001/StockItem?$filter=ItemStatus eq 'Active'&$top=9
Hi Andrew,
You can use it like this:
http://[Base endpoint URL]/[Top-level entity]/[Action name]
You use the POST HTTP method and pass the record to which the action should be applied and the parameters of the action in the request body in JSON format as follows:
{
"entity" : [record in JSON format],
"parameters" : [parameters in JSON format]
}
Hi Sergey,
{
“entity” : [record in JSON format],
“parameters” : [parameters in JSON format]
}
Can you please give an example for passing the entity. I am getting an error like this:
{
“message”: “The request is invalid.”,
“modelState”: {
“entity”: [
“Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path ‘entity’, line 2, position 13.”,
“The Entity field is required.”
],
“parameters”: [
“Error reading JObject from JsonReader. Current JsonReader item is not an object: Null. Path ‘parameters’, line 119, position 23.”
]
}
}
{
“entity”:
{
“ReferenceNbr” : {“value” : “001824”},
“Type” :{“value” : “Bill”}
},
“parameters” :
{
“OrderNbr”:{“value”: “SC-000003”},
“Selected”:{“value”: “false” }
}
}
I am looking to relate two entities specifically a customer and contacts I thought It would be as easy as passing in an array of contact ids but errors saying fields cannot be empty but everything already exists I just want to relate the objects. Would I do this through an action?
How do I get a list of all the actions?
How come sometimes it says that x is not defined in the dictionary ? Can I get a list of things that are defined in the each dictionary?
Hi Ed,
I’m not sure if I got your question correctly, but if you want to attach new contact to customer, you should work thought screen – contacts and than specify there BAccount. Than Contact will be linked to customer.
If you mean something else, please give me more details about command you use and exact error message with stack trace.
Hi,
Thanks for the article, could you provide an example using an action?