Steps to hit
webservice from POSTMAN REST Client
- Rest Service Class in Salesforce
@RestResource(urlMapping='/UpdateMerchantAssetStatus/*')
global with sharing class RESTMerchantAssetController{
@HttpPost
global static ResponseHandler UpdateMerchantAssetStatus(String MerchantAssetId, String Status,
String OrgId,String ThumbName,String FileName,String DisplayName,
String FileHeight, String FileWidth, String FileURL){
ResponseHandler response = new ResponseHandler();
Merchant_Asset__c objMerchantAsset=new Merchant_Asset__c(id=MerchantAssetId,Status__c=Status,
Salesforce_Org_ID__c=OrgId,File_Width__c=FileWidth,
File_URL__c=FileURL,File_Name__c=FileName,File_Height__c=FileHeight,
Display_Name__c=DisplayName);
System.debug('MerchantAssetId: '+MerchantAssetId);
System.debug('Status '+Status);
try{
update objMerchantAsset;
sobject objAsset=new Merchant_Asset__c();
objAsset=(sobject)objMerchantAsset;
response.Data = objAsset;
response.Status = 'Success';
}catch(Exception exp){
response.Status = 'Fail';
}
return response;
}
}
global with sharing class RESTMerchantAssetController{
@HttpPost
global static ResponseHandler UpdateMerchantAssetStatus(String MerchantAssetId, String Status,
String OrgId,String ThumbName,String FileName,String DisplayName,
String FileHeight, String FileWidth, String FileURL){
ResponseHandler response = new ResponseHandler();
Merchant_Asset__c objMerchantAsset=new Merchant_Asset__c(id=MerchantAssetId,Status__c=Status,
Salesforce_Org_ID__c=OrgId,File_Width__c=FileWidth,
File_URL__c=FileURL,File_Name__c=FileName,File_Height__c=FileHeight,
Display_Name__c=DisplayName);
System.debug('MerchantAssetId: '+MerchantAssetId);
System.debug('Status '+Status);
try{
update objMerchantAsset;
sobject objAsset=new Merchant_Asset__c();
objAsset=(sobject)objMerchantAsset;
response.Data = objAsset;
response.Status = 'Success';
}catch(Exception exp){
response.Status = 'Fail';
}
return response;
}
}
2. global class ResponseHandler {
public String Status {get; set;}
public sObject Data {get;set;}
}
- Launch POSTMAN and click on OAuth 2.0 tab and then click on ‘Get Access Token’ button:
- Fill following required details as below: Client Id & Client secret can be generated by creating a connected App in salesforce
a. Authorization
URL: https://test.salesforce.com/services/oauth2/authorize
b. Access
Token URL: https://test.salesforce.com/services/oauth2/token
c. Client
ID: 3MVG9zZht._ZaMukxu8cN6FHUteykMdv8YNVOeMm1oUTM1hSuZLZT.mPs628tZLkX2RsXZgJ5sFWk9t2lQOS0
d. Client
Secret: 1837523717317747721
- Fill the Salesforce User name and password and click on ‘Log in to Salesforce’ button
- if everything is correct, you will get success screen with access token details:
- save the token and now put the details as below:
a. End
point URL: https://cs21.salesforce.com/services/apexrest/UpdateMerchantAssetStatus
b. Select
method as ‘POST’
c. Put
the details in header as below:
Authorization: OAuth + Access
Token[as received in step 4]
Content-Type: application/json
{
"MerchantAssetId" :
"a2yq00000008U0t",
"Status" :
"Approved",
"OrgId" :
"00Dq0000000AlSW",
"FileWidth" :
"250",
"FileHeight" :
"250",
"FileURL" :
"www.google.com",
"FileName" :
"TestFile2",
"DisplayName" :
"TestFile2"
}
e. Click
on ‘Send’ button
- If everything is correct there will be success response as below:






No comments:
Post a Comment