You need to sign in to do that
Don't have an account?

Apex Rest to update account
Hi Experts,
I need to update accountnumber in account using rest services.
Need your help on code snippet to update.
I tried the below code but getting error when trying to update.
Error
System.QueryException: List has no rows for assignment to SObject Class.RESTClass.updateAccount: line 7, column 1
Let me know what I need to change to make this work.
Thanks
I need to update accountnumber in account using rest services.
Need your help on code snippet to update.
I tried the below code but getting error when trying to update.
Error
System.QueryException: List has no rows for assignment to SObject Class.RESTClass.updateAccount: line 7, column 1
@HttpPatch global static String updateAccount(string accnumber){ String accid1 = RestContext.request.params.get('id'); Account acc = [select accountnumber from account where id =: accid1]; acc.accountnumber = accnumber; update acc; return 'account updated'; }
Let me know what I need to change to make this work.
Thanks
Are you sure the JSOn you are getting is having "id" field containing Account Id?