1

For instance, let's say you want to serve up contact 1111111's data.

I know you can make an endpoint like /contacts?id=1111111

Is it possible to have an endpoint like /contacts/1111111 where the apex code is able to get the value 1111111 instead of using a query parameter like the first example?

2

Yes, you can parse RestContext.request.requestURI to get that sort of information.

@RestResource(UrlMapping='/contacts/*')
global with sharing class MyRestService
{
    @HttpPost
    global static void doPost()
    {
        List<String> path = RestContext.request.requestURI.split('/');
        // check for specific elements in the path
    }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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