1
2Map<String, Object> nsAttachReference = new Map<String, Object>();
3nsAttachReference.put('attachTo', new Map<String, Object>{'internalId'=>'120956','type'=>'salesOrder'});
4nsAttachReference.put('contact', new Map<String, Object>{'internalId'=>'15959'});
5
6Map<String, Object> nsAttachment = new Map<String, Object>();
7nsAttachment.put('attachReference',nsAttachReference);
8
9// Initialize the RequestJSON Data to be passed.
10Map<String, Object> requestJSONMap = new Map<String, Object>();
11requestJSONMap.put('attachContacts', new List<Object>{nsAttachment});
12String reqJSON = JSON.serialize(requestJSONMap);
13
14Map<String, Object> reqObj = new Map<String, Object>();
15reqObj.put('version', '1.0');
16reqObj.put('action', 'attachContact');
17reqObj.put('requestJSON', reqJSON);
18
19// Placing a request to Breadwinner Global API
20Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
21System.debug(resp);