function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
karimulla testingkarimulla testing 

Error: Compile Error: Unexpected token 'List'. at line 131 column 1

/*********************************************************************

* Description - Apex REST service with GET and POST methods

* Author - AP

<u>Json format</u>

{

"name" : "Akash",

"phone" : "8826031286",

"website" : "www.akashmishra.co.in"

}

***********************************************************************/

@RestResource(urlMapping='/v3/accounts/*')

global with sharing class REST_AccountService_V4 {

@HttpPost

global static AccountWrapper doPost(String name, String phone, String website) {

RestRequest req = RestContext.request;

RestResponse res = RestContext.response;

AccountWrapper response = new AccountWrapper();

Account acct = new Account();

acct.Name = name;

acct.Phone = phone;

acct.Website = website;

insert acct;

response.acctList.add(acct);

response.status = 'Success';

response.message = 'Your Account was created successfully.';

return response;

}

@HttpGet

global static AccountWrapper doGet() {

RestRequest req = RestContext.request;

RestResponse res = RestContext.response;

AccountWrapper response = new AccountWrapper();

String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);

if(doSearch(accountId))

{

searchAccounts(req, res, response);

}

else

{

findAccount(res, response, accountId);

}

return response;

}

// If the item to the right of the last forward slash is "accounts", the request went to

//v3/accounts?Name=Akash

// Else the request went to v3/accounts/&lt;something&gt;, which is not a search, but a specific

//entity

private static boolean doSearch(String accountId) {

if(accountId == 'accounts') {

return true;

}

return false;

}

//If the request came to /v3/accounts, then we want to execute a search

Public static void searchAccounts(RestRequest req, RestResponse res,

AccountWrapper response) {

//Use the RestRequest's params to fetch the Name parameter

String searchTerm = req.params.get('Name');

if(searchTerm == null || searchTerm == '') {

response.status = 'Error';

response.message = 'You must provide a Name for your search term.';

res.StatusCode = 400;

}

else {

String searchText = '%'+searchTerm+'%';

List&lt;Account&gt; searchResults =

[SELECT Id, Name, Phone, Website FROM Account WHERE Name LIKE : searchText];

if(searchResults != null &amp;&amp; searchResults.size() &gt; 0) {

response.acctList = searchResults;

response.status = 'Success';

response.message = searchResults.size()

+ ' Accounts were found that matched your search term.';

}

else {

response.status = 'Error';

response.message =

'No Accounts were found based on that Name, please search again.';

}

}

}

&nbsp;

//If the request came to v3/accounts/sometext then we want

//to find a specific account

Public static void findAccount(RestResponse res, AccountWrapper response,

String accountId) {

// Provided we recevied an External Id, perform the search and return the results

if(accountId != null &amp;&amp; accountId != '') {

List&lt;Account&gt; result = [SELECT Id, Name, Phone, Website FROM Account

WHERE External_Id__c =: accountId];

if(result != null &amp;&amp; result.size() &gt; 0) {

response.acctList.add(result[0]);

response.status = 'Success';

}

else {

response.status = 'Error';

response.message = 'This account could not be found, please try again.';

res.StatusCode = 404;

}

}

// If the request came to /v3/accounts/ (without an Account Id),

//return an error

else {

response.status = 'Error';

response.message = 'You must specify an External Id.';

res.StatusCode = 400;

}

}

global class AccountWrapper {

public List&lt;Account&gt; acctList;

public String status;

public String message;

public AccountWrapper(){

acctList = new List&lt;Account&gt;();

}

}

}



can anybody resolve this issue
 
Best Answer chosen by karimulla testing
Aslam ChaudharyAslam Chaudhary
Repalce below in your code 
List&lt;  to <
t&gt;  to >
&amp; to &

All Answers

Aslam ChaudharyAslam Chaudhary
Repalce below in your code 
List&lt;  to <
t&gt;  to >
&amp; to &
This was selected as the best answer
karimulla testingkarimulla testing
thankyou #aslam chaudary