You need to sign in to do that
Don't have an account?
Ariel Siler 6
Anonymous site apex rest endpoint stopped working after moving the apex class into a managed package
I have an anonymous site to make unauthenticated rest requests that activates my apex class method;
everything was worked fine when i called the following endpoint:
https://MySiteName.eu6.force.com/services/apexrest/MyEndpointName
And it activated the following apex:
All the documentation talking about apex rest in managed packaged didn't talk about how it affects the url on anonymous requests made to a site.
they all sort of say to add the namespace prefix as the beginning sub domain like this:
https://MyNamespace.eu6.force.com/services/apexrest/MyEndpointName
or to add it before the endpoint name like this:
https://eu6.force.com/services/apexrest/MyNamespace/MyEndpointName
but none of them talks about how to handle sites like my case.
I tried all possible variations i could think of like:
https://MyNamespace.MySiteName.eu6.force.com/services/apexrest/MyEndpointName
https://MySiteName.eu6.force.com/services/apexrest/MyNamespace/MyEndpointName
and more adding the __ but none worked.
Eventually i got it working by adding a wildcard (*) to my urlMapping like this:
and then the following endpoint started working:
https://MySiteName.eu6.force.com/services/apexrest/MyNamespace/MyEndpointName
The thing is that i'm worried about that wildcard because i don't understand why it works and the possible consequences.
when i use the following endpoint:
https://MySiteName.eu6.force.com/services/apexrest/NOTMYNAMESPACE/MyEndpointName
it doesn't work which is good, but stil i prefer to put in my urlMapping something implicit that will work.
when i tried to change the urlMapping into this:
everything was worked fine when i called the following endpoint:
https://MySiteName.eu6.force.com/services/apexrest/MyEndpointName
And it activated the following apex:
@RestResource(urlMapping='/') global with sharing class MyEndpointName { @httpGet global static Integer xxx() { ... }But after moving the class into a new managed package the endpoint stopped working.
All the documentation talking about apex rest in managed packaged didn't talk about how it affects the url on anonymous requests made to a site.
they all sort of say to add the namespace prefix as the beginning sub domain like this:
https://MyNamespace.eu6.force.com/services/apexrest/MyEndpointName
or to add it before the endpoint name like this:
https://eu6.force.com/services/apexrest/MyNamespace/MyEndpointName
but none of them talks about how to handle sites like my case.
I tried all possible variations i could think of like:
https://MyNamespace.MySiteName.eu6.force.com/services/apexrest/MyEndpointName
https://MySiteName.eu6.force.com/services/apexrest/MyNamespace/MyEndpointName
and more adding the __ but none worked.
Eventually i got it working by adding a wildcard (*) to my urlMapping like this:
@RestResource(urlMapping='/*') global with sharing class MyEndpointName { @httpGet global static Integer xxx() { ... }
and then the following endpoint started working:
https://MySiteName.eu6.force.com/services/apexrest/MyNamespace/MyEndpointName
The thing is that i'm worried about that wildcard because i don't understand why it works and the possible consequences.
when i use the following endpoint:
https://MySiteName.eu6.force.com/services/apexrest/NOTMYNAMESPACE/MyEndpointName
it doesn't work which is good, but stil i prefer to put in my urlMapping something implicit that will work.
when i tried to change the urlMapping into this:
@RestResource(urlMapping='/MyNamespace') global with sharing class MyEndpointName { @httpGet global static Integer xxx() { ... }It didn't work for that endpoint,