You need to sign in to do that
Don't have an account?

To change an array to normal form in Json data
I have the below JSON POST callout class. The data is sent in an array format whereas the destination requires it in just normal format. please suggest to remove the array in this code an execute in normal format. Please help. I just want it to send data in normal format and not in an array.
public class WebServiceCallout { @future (callout=true) public static void sendNotification(string Id,string Email,string First_Name,string Last_Name,string phone,string Title,string Account) { conweb cont=new conweb(Id,Email,First_Name,Last_Name,Phone,Title,Account); List<conweb> conwebs=new List<conweb>(); conwebs.add(cont); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); req.setTimeout(2000); // timeout in milliseconds req.setEndpoint('http://178.62.64.210/api/user'); req.setMethod('POST'); req.setHeader('Content-Type','application/json'); req.setHeader('Authorization','gfkj^%$654GF65yhtd54'); req.setBody(JSON.serialize(conwebs)); //req.setBody('Id='+EncodingUtil.urlEncode(Id, 'UTF-8')+'&Email='+EncodingUtil.urlEncode(Email, 'UTF-8')+'&First_Name='+EncodingUtil.urlEncode(First_Name, 'UTF-8')+'&Last_Name='+EncodingUtil.urlEncode(Last_Name, 'UTF-8')); //req.setCompressed(true); // otherwise we hit a limit of 32000 try { res = http.send(req); } catch(System.CalloutException e) { System.debug('Callout error: '+ e); System.debug(res.toString()); } } public class conweb { String salesForceId; String emailAddress; String firstName; string lastName; string contactNumber; string jobTitle; string companyName; public conweb(string sid,string semail,string sfirstname,string slastname,string sphone,string Title,string Account) { salesForceId=sid; emailAddress=semail; firstName=sfirstname; lastName=slastname; contactNumber=sPhone; jobTitle=Title; companyName=Account; } }}
All Answers
As of now you are creating a list of the wrapper which an array, make an instance of the wrapper class and then populate it ans send it.
Like
Let me know if it works
Many Thanks in advance.. Made my Day.. :)
Contact con = [Select Id, Account.Name From Contact];
WebServiceCallout.sendNotification(c.Id,c.Email,c.FirstName,c.LastName,c.phone,c.Title__c,c.Account.name);