1

i have written a rest web service class and mapped the resource as '/Accounts/*/contacts'. where * stands for Accountid.

I am trying to do a POST call from workbench and having issue writing server URI.

for example: suppose a resource mapping is "/Accounts/*", it corresponding URI mapping for doing POST call through workbench will be : /services/apexrest/Accounts/.

Similarly, Please suggest how to write URI in workbench for resource mapping '/Accounts/*/contacts'. Thanks in advance.

1 Answer 1

5

The * is a wildcard. It just allows Salesforce to map the URL to your class when a parameter is included. To use your example,

/Accounts/*

can map the URL

/services/apexrest/Accounts/PARAMETER

where your class can parse and utilize the parameter value - an Account Id or External Id, for example.

Interstitial wildcards do the same thing.

/Accounts/*/Contacts

would map the URL

/services/apexrest/Accounts/PARAMETER/Contacts

to, for example, return data about the Contacts associated with the Account identified by the value PARAMETER.

For more, see RestResource Annotation:

URL path mappings are as follows:

The path must begin with a '/'
If an '*' appears, it must be preceded by '/' and followed by '/', unless the '*' is the last character, in which case it need not be followed by '/'

Salesforce does not parse the URL into parameters for your class; you're responsible for inspecting the incoming request and parsing and validating any parameters you expect. If your web service does not accept any parameters, I don't see any reason why you'd use a wildcard in your URL mapping.

You must log in to answer this question.

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