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
SatmetrixSatmetrix 

Rest resource NewWeb service requires test method

Hi All Friends,


I wrote a new REST Web service which works well for an update while calling from out side.

But not able to package it,because it required test methods.

The below is the REST web service written in apex class.Please help write test methods.

 

Thanks
Pradeep

 

@RestResource(urlMapping='/Contacts/*')

global with sharing class MyRestResource {

@HttpPost

global static String doPost(RestRequest req, RestResponse res, String NPS)

 {

 String contactId= req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);

 Contact contact= [SELECT AccountID,NPS__c FROM Contact WHERE Id=:contactId];

contact.NPS__c= NPS; update contact; return contact.NPS__c;

}

 }