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
Abhilash MAbhilash M 

Error while implementing a REST Service

Below is my code

@RestResource(urlMapping='/v1/accounts/*')
global with sharing class REST_AccountService_V1 {
@HttpGet
global static Account doGet() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Account result = [SELECT Id, Name, Phone, Website, BillingState FROM Account WHERE External_Id__c = :accountId];
return result;
}
}

When I try to test the above Rest service in SOAPUI Tool
I am getting an error as below:




[ERROR:]Service not found at: /services/apexrest/AccountRaw ResponseHTTP/1.1 404 Not Found Date: Fri, 30 Oct 2015 06:35:33 GMT Set-Cookie: BrowserId=-MDkUrODQ_K2MkY-SmGwqw;Path=/;Domain=.salesforce.com;Expires=Tue, 29-Dec-2015 06:35:33 GMT Expires: Thu, 01 Jan 1970 00:00:00 GMT Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked
[ { "errorCode" : "NOT_FOUND", "message" : "Could not find a match for URL /Account" } ]

Do I need to create a Remote site URL also ?How does it help? 
AshlekhAshlekh
Hi,

You need to hit the request with below url and add some parameter.

https://instance.salesforce.com/services/apexrest/v1/accounts/

Add header paramters
1) Authorization: 'Bearer '+SessionId or accesstoken
2) Content-Type : application/json

https://developer.salesforce.com/docs/atlas.en-us.apex_workbook.meta/apex_workbook/apex_rest_3.htm

-Thanks
Ashlekh Gera
pconpcon
If you are using a *nix based system (such as any linux os or OSX) you can use these command line scripts to help you

https://gist.github.com/pcon/54e8b0d7518d8fe42c79
v varaprasadv varaprasad
Hi Please check once below link.i t may helps you.

http://salesforceprasad.blogspot.in/2014/12/rest-web-services.html

Thanks
Varaprasad
Keshab AcharyaKeshab Acharya
Abhiram are you still facing issue?