function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ManojKumar MuthuManojKumar Muthu 

Unexpected parameter encountered during deserialization for case attachment

HI there,

Below my code was working fine, but suddenly pass an error, when I try to attach a document,

Custom API for Case Attachment,
@RestResource(urlMapping='/CaseAttachment/*')
global with sharing class CaseAttachment{

@HttpGet
    global static List<Attachment> getCaseById() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
          List<Attachment> result =  [Select id, Name, OwnerId, BodyLength, LastModifiedById, LastModifiedDate, ContentType, Body, Description, CreatedDate, CreatedById from Attachment where ParentId = :Id];
        return result;
        }
           
@HttpPost
  global static void doget(String type, String body, String ContentType, String ParentID){

        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        if(Test.isRunningTest()){
        String CaseName=req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        //String doc=EncodingUtil.Base64Encode(req.requestBody);
        }
        
         Attachment a = new Attachment();
            a.Name = type;
            a.Body = Blob.valueOf(body);           
            a.ContentType = ContentType;
            a.ParentId = ParentID;
                
        insert a;
        
        
    }
}

Below the resultUser-added imageCan someone help with this asap.
Best Answer chosen by ManojKumar Muthu
Raj VakatiRaj Vakati
Try this  .. Please update the correct parent Id
 
{
	"type": "test", 
	"body": "test", 
	"ContentType": "text", 
	"ParentID": "500..........W"
}

 

All Answers

Raj VakatiRaj Vakati
Try this  .. Please update the correct parent Id
 
{
	"type": "test", 
	"body": "test", 
	"ContentType": "text", 
	"ParentID": "500..........W"
}

 
This was selected as the best answer
ManojKumar MuthuManojKumar Muthu
@Raj 
Now its working fine