I'm trying to send data from one SFDC org to another org via Rest API. I'm properly able to create Rest Resource in 'receiving org' in this way :
@httpPost
global static string DepositAmount(string Accountid, integer amount, date depositDate)
{
// ----My code doing processing
}
'Sending org' is sending data entered by user via VF page(using custom controller). As mentioned, user in inputting data in 3 fields of types :
1. Text
2. Number
3. Date
Now I'm able to make successful Rest API call if I send 'hardcoded' values to 'receiving org for above 3 fields in this way :
String strbody = '{ "AccountId" : "0019000001Gchjb", "depositAmount" : "4555", "depositDate" :"06/01/2014" }'
req.setBody(strbody);
But I'm unsure How to set input Fields as request body for the API call ? I was thinking to try JSON serialization using Maps
Map<String,String> postBody = new Map<String,String>();
But Maps accepts data of one type. Here I've 3 types of Data . If I convert my data into string, my receiving org starts giving error as it accepts 3 values of different types( string, number, date)
How could I proceed to set body in receiving org ?