Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am building an apex REST service to be hosted on a public site using the approach outlined here (basically hosting a REST service on a site allows you to perform actions against it without authentication, which is nice for javascript integration).

http://blogs.developerforce.com/developer-relations/2012/02/quick-tip-public-restful-web-services-on-force-com-sites.html

My service works perfectly in Sandbox, but when attempting to access it in prod, it always throws

<Errors>
    <Error>
        <errorCode>UNSUPPORTED_CLIENT</errorCode>
        <message>HTTPS Required</message>
    </Error>
</Errors>

This error happens even when accessing the service via HTTPs.

Here is my functional sandbox one https://fpitesters.testbed.cs7.force.com/webServices/services/apexrest/respondentPortal/

You will get an auth token error there, that is expected. It's just a basic security measure.

And here is the production one https://fpitesters.force.com/webServices/services/apexrest/respondentPortal/

UPDATE: So as Josh Birk pointed out, you do need to use the secure sub domain. If you try to just use HTTPs on the regular URL you do get redirected to a regular http domain. So with that in mind, the url for my service should be

https://fpitesters.secure.force.com/webServices/services/apexrest/respondentPortal/

However that URL says that the service couldn't be found.

<Errors>
    <Error>
        <errorCode>NOT_FOUND</errorCode>
         <message>Could not find a match for URL /respondentPortal/</message>
    </Error>
</Errors>

Not really sure where to go from here. Is this a bug?

share|improve this question
    
Did you check if you have any URL Redirect Rules set-up? I tried to spin some a small service in my dev org and it is working fine. Kind of a mystery for me though. –  logontokartik Jan 10 '13 at 17:05
    
Here is the service i added polyglot-developer-edition.na14.force.com/services/apexrest/… –  logontokartik Jan 10 '13 at 17:06
    
I did find out that you need to use the secure.force.com sub domain. The only problem is when using that, it cannot find my REST service. So [fpitesters.secure.force.com/webServices/services/apexrest/… Which should be the valid location says it cannot be found. That should be the correct location, so I'm at a bit of a loss. Almost starting to think this is a bug. Works perfectly in sandbox, fails in prod. –  Kenji776 Jan 10 '13 at 18:14
3  
Seems like a bug to me. Is the 'webServices' path components a namespace? (It looks like it, but the docs say that the namespace goes after /services/apexrest/) You could try with a REST method in an Apex class outside the namespace. It might be a bug when we parse the URL - the 'secure' component may be confusing the parsing code. –  metadaddy Jan 10 '13 at 21:06
    
webServices is not a namespace. It is just the name of the site. I am not using any namespacing for this project. Who would be my best person to contact if this is indeed a bug? –  Kenji776 Jan 11 '13 at 16:06
add comment

3 Answers

Your production endpoint is only HTTP however. Remember that secure Force.com site has a specific domain, so I think you need:

https://fpitesters.secure.force.com/FPITestersIndex

share|improve this answer
    
The lack of the s was a typo on my part. Are you able to access it from that address? I am almost starting to think there is some kind of weird redirect going on, since I did copy that address I pasted from my URL bar after going to the HTTP address. Also, attempting to access fpitesters.secure.force.com/webServices/services/apexrest/… said that there was no matching URL. –  Kenji776 Jan 10 '13 at 16:24
    
Another test indicates that it is indeed due to a redirect. Accessing the https version gets you back a 301 (moved permanently) which then leads to the http version. So that must be the secure subdomain you mentioned. Now I'm just not sure why the secure version says my service doesn't exist. Redirect –  Kenji776 Jan 10 '13 at 16:29
add comment
up vote 3 down vote accepted

Got it figured out. It was due to a permissions error it seems. Somehow an object for the services profile had an impossible permission setup (it had full read write modify all on an child object where it did not have read write modify all on the parent object (an opportunity)). So fixing the permissions and making sure the service had read/write to all objects and fields it required seems to have fixed this error.

share|improve this answer
    
Cool - be sure to 'accept' this answer when you can! –  metadaddy Jan 14 '13 at 17:59
add comment

I was receiving the same error:

Could not find a match for URL 

but the issue turned out to be namespacing. The Apex controller had Namespace Prefix mynamespace, with @RestResource(urlMapping='/Widgets/*'), and the URL ended up being

https://mydomain.myhost.force.com/mysitecustomurl/services/apexrest/mynamespace/Widgets/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.