Solved

Updating customer


Userlevel 1
Badge

Im sorry for asking too many questions, but this system’s documentation is the most poor ive ever faced.

Im trying to update customer via REST API and request stucks, loads for infinite and does nothing. The URL and data array and customer details are below. Wat im doing wrong? Thanks.

 

icon

Best answer by skater4 1 June 2022, 20:11

View original

12 replies

Userlevel 7
Badge +5

Could you post the data in the format you are submitting it?

The current format does not look correct at all. 

Is should be JSON format, see here:

https://help.acumatica.com/(W(13))/Help?ScreenId=ShowWiki&pageid=7b104d41-3457-42f8-8010-165d9d931d3f

 

Should be something like this:

{
"CustomerName" : {value: "TEST"}
"MainContact" :
{
"Email" : {value : "demo@gmail.com" },
"Address" :
{
"AddressLine1" : {value : "4030 Lake Washington Blvd NE" },
"AddressLine2" : {value : "Suite 100" },
"City" : {value : "Kirkland" },
"State" : {value : "WA" },
"PostalCode" : {value : "98033" }
}
}
}

 

Userlevel 1
Badge

Could you post the data in the format you are submitting it?

The current format does not look correct at all. 

Is should be JSON format, see here:

https://help.acumatica.com/(W(13))/Help?ScreenId=ShowWiki&pageid=7b104d41-3457-42f8-8010-165d9d931d3f

 

Should be something like this:

{
"CustomerName" : {value: "TEST"}
"MainContact" :
{
"Email" : {value : "demo@gmail.com" },
"Address" :
{
"AddressLine1" : {value : "4030 Lake Washington Blvd NE" },
"AddressLine2" : {value : "Suite 100" },
"City" : {value : "Kirkland" },
"State" : {value : "WA" },
"PostalCode" : {value : "98033" }
}
}
}

 

Sure its JSON, here it is

  1. {"CustomerName":{"value":"Customer Customer"},"MainContact":{"Email":{"value":"manager@cs-coding.com"},"FirstName":{"value":"Customer"},"LastName":{"value":"Customer"},"Phone1":{"value":"+7(777)777-77-77"},"Address":{"AddressLine1":{"value":"44 Main street"},"AddressLine2":{"value":""},"City":{"value":"Boston"},"Country":{"value":"US"},"PostalCode":{"value":"02134"},"State":{"value":"MA"}}}}
  2.  
Userlevel 7
Badge +5

Ok, this looks fine. 

Could you try removing the $expand and $filter parameters from your URL and post it with a simplified URL?

Userlevel 1
Badge

Ok, this looks fine. 

Could you try removing the $expand and $filter parameters from your URL and post it with a simplified URL?

but it will update all other values?

Userlevel 7
Badge +5

The URL parameters do not affect the way the data is updated. 

Userlevel 1
Badge

The URL parameters do not affect the way the data is updated. 

waaaaat?? documentation says that wilter param is to select wat data will update, no?

 

*Dmitrii, do u speak rus?)

Userlevel 1
Badge

The URL parameters do not affect the way the data is updated. 

Does it mean that filter specifies row that will be updated? and if its empty ALL data will be updated?

 

Userlevel 7
Badge +5

I was not completely correct in my previous comment.

There are several ways to identify a data record that needs to be updated. 

The most standard one is to use ID or Key fields of the record to update it. 

E.g. if you send the data like that:

{
"id": "1327a80f-c178-490d-9552-9fc125a8aa02",
"CustomerName" : {value: "TEST"}
"MainContact" :
{
"Email" : {value : "demo@gmail.com" },
"Address" :
{
"AddressLine1" : {value : "4030 Lake Washington Blvd NE" },
"AddressLine2" : {value : "Suite 100" },
"City" : {value : "Kirkland" },
"State" : {value : "WA" },
"PostalCode" : {value : "98033" }
}
}
}

The customer with ID=1327a80f-c178-490d-9552-9fc125a8aa02 will be updated.

However, there is indeed one case when you may want to use $filter to identify the record that you are going to update. That case is when you need to identify the record by some non-key fields, e.g. customer email. That is relatively rare case.

 

However, the situation in which multiple records are being updated is not possible. If your filtering condition does not allow the system to select a single record to update, it’ll throw an error. It’ll not update more than one record per request.

 

So, yes, $filter may be used to determine a record to update. 

 

All other parameters only affect the format of the response.

 

P.S. Yes, I do speak russian

Userlevel 1
Badge

I was not completely correct in my previous comment.

There are several ways to identify a data record that needs to be updated. 

The most standard one is to use ID or Key fields of the record to update it. 

E.g. if you send the data like that:

{
"id": "1327a80f-c178-490d-9552-9fc125a8aa02",
"CustomerName" : {value: "TEST"}
"MainContact" :
{
"Email" : {value : "demo@gmail.com" },
"Address" :
{
"AddressLine1" : {value : "4030 Lake Washington Blvd NE" },
"AddressLine2" : {value : "Suite 100" },
"City" : {value : "Kirkland" },
"State" : {value : "WA" },
"PostalCode" : {value : "98033" }
}
}
}

The customer with ID=1327a80f-c178-490d-9552-9fc125a8aa02 will be updated.

However, there is indeed one case when you may want to use $filter to identify the record that you are going to update. That case is when you need to identify the record by some non-key fields, e.g. customer email. That is relatively rare case.

 

However, the situation in which multiple records are being updated is not possible. If your filtering condition does not allow the system to select a single record to update, it’ll throw an error. It’ll not update more than one record per request.

 

So, yes, $filter may be used to determine a record to update. 

 

All other parameters only affect the format of the response.

 

P.S. Yes, I do speak russian

So здравствуйте) основная проблема пока в том что оно повисает на этом запросе и грузится бесконечно. Это может быть связано с тем что там десятки тысяч записей? 

 

Userlevel 7
Badge +5

The official language of the community site is English so I’d stick to that. 

 

The loading time indeed depends on two main factors:

  1. Number of records
  2. Filtering condition

If the filtering condition does not follow the indexes the table have, it may indeed take a long time to load. 

 

However, at that point I’m not sure whether it’s data retrieval or data updating process that is causing the delay. 

I’d suggest you to start with a simple Get request to at least read the record. Then if reading succeeds you can proceed to update the record. 

Userlevel 1
Badge

Thanks, Ill try

Userlevel 1
Badge

The official language of the community site is English so I’d stick to that. 

 

The loading time indeed depends on two main factors:

  1. Number of records
  2. Filtering condition

If the filtering condition does not follow the indexes the table have, it may indeed take a long time to load. 

 

However, at that point I’m not sure whether it’s data retrieval or data updating process that is causing the delay. 

I’d suggest you to start with a simple Get request to at least read the record. Then if reading succeeds you can proceed to update the record. 

 

I defined id field in request and now it worked, thanks!

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