Path Parameter
Path parameters are variable parts of a URL path. They are typically used to point to a specific resource within a collection, such as a user identified by ID. A URL can have several path parameters, each denoted with curly braces { }
Query Parameter
Query parameters are a defined set of parameters attached to the end of a url. They are extensions of the URL that are used to help define specific content or actions based on the data being passed
Header
Parameters included in the request header, usually related to authorization
There are two type of parameter:
- Static parameter
- Dynamic parameter
Static Parameter
In case of static Path Parameters, static Query parameters, static Headers we can set directly from the Rest Adapter Properties.
your URL will be generated like
example:http://test.salesforce.com/Rest/Service/path1??Id=test&Uname=Account1
Dynamic Parameter:
In case of dynamic Path Parameter and dynamic Query Parameter and dynamic Header means value comes from the business sObject like Account.
follow the adapter screen how to set dynamic path, query, and header variable inside adapter screen properties:
There are 2 ways to set the Parameter:
1)value comes from the Map variables.
2)value comes from the salesforce sObject example: Account
1)value comes from the Map variables: #
[aux_code language=”javascript” theme=”tomorrow” title=”” extra_classes=””]Map<String,String> pathParam = new Map<String,String>();pathParam.put(‘UId’,’/rest/get’);
pathParam.put(‘SobjCode’,’/service’);
Map<String,String> queryParam = new Map<String,String>();
queryParam.put(‘UName’,’Account1′);
queryParam.put(‘RecId’,’R01′);
Map<String,String> headerParam = new Map<String,String>();
headerParam.put(‘AuthPermission’,’All’);
headerParam.put(‘AuthId’,’A01′);[/aux_code]
c.returnJSONComplete=true;
c.actionDoIntegrate=true;
c.isCreateMessage=true;
c.pathParam = pathParam;
c.queryParam = queryParam;
c.headerParam = headerParam;
String[] ids= new String[]{‘0013E000019UnjEQAS’}; //Account Id
skyvvasolutions.Iservices.invokeCalloutV3(‘Test_Integration’,’Test_Interface’,ids,’SYNC’,c);[/aux_code]
2)Value comes from the salesforce sObject: #
Here we are taking Account sObject example. We have to use Skyvaa mapping tool nd value come from the Source/Target Name object. Here we are passing account Id during callout and contact is a child object of account then contact sObject fields are not used as a query, path, and header parameter.
Mpping tool looks like:
If the the parent sobject is an account then we have o map the path parameter with account sobject.
In case of static Path Parameters, static Query parameters, static Headers we can set directly to the Rest Adapter Properties.
Updated with New Way Dynamic Header, Dynamic Query Parameter and Dynamic Path Parameter #
Comparison #
Old Way: (key and value both are replacing) # |
New Way: (replacing only value key is static when we are using dynamic query and header parameter) # |
Adapter property: Header: {!authorizationCode} replacing key and value in apex side base on mapping |
Adapter Property Header: authorizationCode = {!authorizationCodeValue} authorizationCodeValue is coming from the mapping. Replacing only value in apex side base on mapping authorizationCode = Basic adasdnasjkdn213123123 |
Actual value: Header : authorizationCode = Basic adasdnasjkdn213123123 |
Actual value: Header: authorizationCode = Basic adasdnasjkdn213123123 |
REST URL Path Parameter: /{!Path1}/{!Path2} Path1 and Path2 value is coming from the mapping. |
REST URL Path Parameter: /{!Path1}/{!Path2} Path1 and Path2 value is coming from the mapping. |
Actual value: REST URL Path Parameter: /rest/service |
Actual value: REST URL Path Parameter: /rest/service |
REST URL Query Parameter: ?{!Name}&{!City} Name and City is coming from the mapping. |
REST URL Query Parameter: ?Name={!NameValue}&City= {!CityValue} NameValue and CityValue is coming from the mapping. Replacing only value in apex side base on mapping |
Actual value: REST URL Path Parameter: ?Name=account1&City=abc |
Actual value: REST URL Path Parameter: ?Name=account1&City=abc |