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
Yury.KYury.K 

404 Apex REST

Hello,

I'm working with calling APEX REST classes outside of salesforce. 2 month ago I got APEX REST class with long logic which worked perfectly, I called that logic by python script with authorizarion (oAuth 2.0). And now it doesn't work, even when I'm trying to call simple APEX REST like: 


@RestResource(urlMapping = '/test_yury/*')
global with sharing class SAP_BOMclass_Yury_test {

    @HttpGet
    global static string BOMtest(RestRequest req, RestResponse res)
    {
        
        return 'hello there';  
    }      
   
    @HttpPost
    global static string BOMtest1(RestRequest req, RestResponse res)
    {
        
        return 'hello there';  
    }      
} 

I'm calling it by url https://<instance>.salesforce.com/services/apexrest/test_yury with headers 'Authorization' : 'OAuth '+<access_token>(https://<instance>.salesforce.com/services/apexrest/test_yury ws implemented in Remote Access tab).

Also tryed HTTP POST/GET at https://apigee.com , which I saw salesforce used it in some webinar..

 

 

But still I'm getting 404 error :

 

HTTP/1.1 404 Not Found

Date: Mon, 09 Jan 2012 09:44:22 GMT Content-Length: 98 Content-Type: application/json; charset=UTF-8 Connection: close Server: [ { "message": "Could not find a match for URL /test_yury","errorCode": "NOT_FOUND} ]

 

Any ideas why this error started poping up?

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

It appears that your org has a namespace, but you're not including the namespace in the requests.

All Answers

SuperfellSuperfell

I don't beleive that /{foo}/* will match a request to /{foo} which appears to be what you're trying to do, either change the request URL or change the urlMatching parameter.

Yury.KYury.K

Here is some screen shots that can clarify my problem...

 

Apex REST class:

http://img267.imageshack.us/img267/2517/apexclass.png

Remote access tab:

http://img192.imageshack.us/img192/4560/remoteaccess.png

Access token headers(apigee program):

http://img14.imageshack.us/img14/8546/71767084.png

Apigee HTTP POST and 404 error:
http://img846.imageshack.us/img846/6685/apigeepost.png

 

What am I doing wrong?:/

 

Regards,

Yury.

SuperfellSuperfell

It appears that your org has a namespace, but you're not including the namespace in the requests.

This was selected as the best answer
Yury.KYury.K

Simon,

Thank you very much!! 

 

It's working perfectly now.

 

Regards,

Yury.

 

VahidVahid

Hi,

 

I have same issue but can't resolve.

 

Here is my class

 

@RestResource(urlMapping='/restdemo/*')
global with sharing class RESTClassController {
    @HttpGet
    global static List<Contact> getContact(RestRequest req, RestResponse res) {
        //String cName = req.params.get('cname');
        return Database.query('SELECT Id, Name, Email FROM Contact ');
    }
}

 

And I am using apigee, i am calling Webservice as follow:

 

https://ap1.salesforce.com/services/apexrest/restdemo

 

or

 

https://ap1.salesforce.com/services/apexrest/restdemo?name=s

 

This is my response:

HTTP/1.1 404 Not Found

Date: Fri, 10 Feb 2012 15:30:42 GMT Content-Length: 2562 Content-Type: text/html; charset=UTF-8 Connection: close Server: ---------------

Can any one tell me what is the issue. and i don't understand about namespace.

 

Can anyone help me?

 

Thanks

 

VahidVahid

Thanks,

 

I tried with this:

 

https://ap1.salesforce.com/services/apexrest/iBirdsServices/restdemo?name=s

 

or

 

https://ap1.salesforce.com/services/apexrest/00D90000000Hcvq/restdemo?name=s

 

But does not work.

 

Labels for Org Name:

Organization Name = iBirdsServices

 

Salesforce.com Organization ID = 00D90000000Hcvq

 

Am i missing somthing?

 

Thanks

Yury.KYury.K

I'm not sure, but it might help.

try to delete "RestRequest req, RestResponse res", cuz I have heard that some instances are spring 12' already, and there is changes, that you dont need RestRequest and RestResponse in Apex REST classes.

@RestResource(urlMapping='/restdemo/*')
global with sharing class RESTClassController {
    @HttpGet
    global static List<Contact> getContact() {
        //String cName = req.params.get('cname');
        return Database.query('SELECT Id, Name, Email FROM Contact ');
    }
}

Thanks,

Yury.

VahidVahid

Hi,

 

Still not working.... :(

 

@RestResource(urlMapping='/restdemo/*')
global with sharing class RESTClassController {
    @HttpGet
    global static List<Contact> getContact() {
        //String cName = req.params.get('cname');
        return Database.query('SELECT Id, Name, Email FROM Contact ');
    }
}

 

Thanks

VahidVahid

This is response:

 

HTTP/1.1 404 Not Found

Date: Sat, 11 Feb 2012 05:58:05 GMT Content-Length: 2562 Content-Type: text/html; charset=UTF-8 Connection: close Server:

You have attempted to reach a URL that no longer exists on salesforce.com.
VahidVahid

Hi,

 

Find the issue. It just because of new and old apigee console. I was watching demo that is based on old console and there we need to give complete url that begins from https:///...

 

But in new console we just need to give url from services.

 

e.g.

services/apexrest/restdemo

 

Thanks for you help :)

Ankit Gupta SFDCLearnerAnkit Gupta SFDCLearner
Below is an error which I am getting while testing my rest api on workbench
Error:
Raw Response
HTTP/1.1 404 Not Found

Below is my rest class.
/* selflearning is a namespace of my org*/

@RestResource(urlMapping='/selflearning__/accessPobject/*')
global class restServicePObj
{   
    @HttpGet
    global Static List<selflearning__Pobject__c> getPobjectDetails()
    {
        return[select id,Name from selflearning__Pobject__c];
    }
}


Please help me/guide me how I can do this in a right way.



Thanks,
Ankit