0

I followed this tutorial, http://www.wadewegner.com/2013/03/creating-anonymous-rest-apis-with-salesforce-com/ , to create a public rest service in a developer sandbox. If I run any of the following:

curl GET http://sitedomainname.cs1.force.com/services/apexrest/Widgets/
curl POST http://sitedomainname.cs1.force.com/services/apexrest/Widgets/
curl PUT http://sitedomainname.cs1.force.com/services/apexrest/Widgets/
curl DELETE http://sitedomainname.cs1.force.com/services/apexrest/Widgets/

I get an HTTP 301 response.

But strangely, if I run that URL through POSTMAN, any request calls my GET method. And if I run it through SOAP UI, it calls my POST and GET methods correctly.

Finally, if I call the same url, but HTTPS, I get a HTTP 503 error.

Here is my class:

@RestResource(urlMapping='/Widgets/*')
global class WidgetController {

    @HttpGet
    global static String getWidgets() {
        return 'GET';
    }

    @HttpPost 
    global static String createNewWidget() {
        return 'POST';
    }

    @HttpDelete
    global static String deleteWidgetById() {
        return 'DELETE';
    }

    @HttpPut
    global static String updateWidget() {
        return 'PUT';
    }
}

I should also add that all of these methods work correctly when authenticated through workbench.

I have tried this in other sandboxes/editions and I have varying results. Are there any limitations with using this method? Like does it only work in Production and Developer editions?

1 Answer 1

0

I do not have a solution to this per se, but I have identified it is an issue with the particular sandbox in which I was testing the code. Generating a new sandbox and running the same code worked just fine. I'm not sure what settings could've caused the discrepancy (if any). We previously had Salesforce run a fixer on that sandbox because of a separate issue, so maybe there were still some underlying issues that occurred during the provisioning.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .