+ Start a Discussion
Tim BarsottiTim Barsotti 

Is it possible to use attributes with Rest Services?

I have a rest resource configured similar to below. I would like to be able to read the attributes that are passed in with each element, but have not found a way to do this. It appears that SF automatically maps the elements of the request into the user defined object and does not appear to allow me to access any of the attributes. Is there a method to access the original payload?

 

Ideally, I'd like to be able to access project and method from the request as logic is dependent on these fields. 

 

<request project="MyProject" method="NewTest">

     <Field1 attribute1="123">test</Field1>

</request>

 

@RestResource(urlMapping='/test/*')
    global class test{
          @HttpPost
          global static List<String> n(UserDefinedObject UDO){
                RestRequest req = RestContext.request;
                system.debug(req); //does not contain payload
                system.debug(UDO); //Already parsed out object - all attributes are gone

 

Thanks!