0
@RestResource(urlMapping='/UploadDoc/*')
global class CreateNewDoc{

@HttpPost     
 global static void doPost() {
 RestRequest req = RestContext.request;
 RestResponse res = RestContext.response;
 String jsonBody = req.requestBody.toString();
 System.debug('attachmentJSON===='+jsonBody);
 try{ 
    res.responseBody(Blob.valueOf(MyClass.uploadBody(jsonBody)));   
 }
     catch(Exception e){
     System.debug('exception===='+e);
     }
  }
}

I will be hitting the rest url from 3rd party resourse(tring to test via workbench). Here MyClass.uploadBody creates a document and returns the id.

Now I want to return set the Id and return it to the 3rd party as a response body.

I am trying to use the below code which is not working ad throwing me an error

    res.responseBody(Blob.valueOf(MyClass.uploadBody(jsonBody)));  

Method does not exist or incorrect signature: void responseBody(Blob) from the type System.RestResponse

How can I achieve this?

0

Can you try changing

res.responseBody(Blob.valueOf(MyClass.uploadBody(jsonBody)));  

to

res.responseBody = blob.valueOf(MyClass.uploadBody(jsonBody));
0

res.responseBody= Blob.valueOf(MyClass.uploadBody(jsonBody));

Assign the value. response body is not a method. It's an attribute.

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.