Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to access RESTful services which build on force.com platform using Apex

I have create a RESTful service on Force.com using Apex below is my code.

@RestResource(urlMapping='/helloWorld/*')
global with sharing class RestWebservice {

  @HttpGet
  global static String helloWorld(){
    return 'HelloWorld';
  }

}

I am trying to access my RESTful services using below url: https://ap1.salesforce.com/services/apexrest/helloWorld/

In response i am geting:

HTTP/1.1 404 Not Found
Date:Thu, 18 Jul 2013 07:35:44 GMT
Content-Length:96
Content-Type:application/json;charset=UTF-8

[
  {
    "message": "Could not find a match for URL /helloWorld/",
    "errorCode": "NOT_FOUND"
  }
]

Below is my class snapshot: enter image description here

enter image description here

how can i resolve this issue ? Any help is appreciated.

like image 815
Vivek P Avatar asked Jul 18 '13 07:07

Vivek P


People also ask

How do you expose apex as REST service?

To make your Apex class available as a REST web service is straightforward. Define your class as global, and define methods as global static. Add annotations to the class and methods.

What is Apex REST Services permission in Salesforce?

Apex REST means that users can call Apex classes, while API enabled means users can use the API. These are inbound calls to Salesforce, not outbound.


1 Answers

When you putting an * (asterisk) in the end you need to write an Id or something instead of it like is described in this document . What you are trying to accomplish i guess is more like this

 @RestResource(urlMapping='/helloWorld')

And then make this call

curl -H "Authorization: Bearer sessionId"  "https://instance.salesforce.com/services/apexrest/helloWorld"
like image 136
Moti Korets Avatar answered Oct 01 '22 04:10

Moti Korets