You need to sign in to do that
Don't have an account?
Ignacio de la torre
How to save contacts into Salesforce using a response from API call ?
Hi all !
I'm having problems doing this. I need to save the reponse of this API call as Contacts in Salesforce but I can't figure it out.
The result variable looks like this:
I'm stuck here !
Requirement is to connect to this API sending it a clientId and if the client ID exists store the client as a Contact in SF.
Any help would be much apreaciated
I'm having problems doing this. I need to save the reponse of this API call as Contacts in Salesforce but I can't figure it out.
public class GetClient { public List<Object> getClient(String clientId){ Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://api.disputeprocess.com/api/v1/clients?clientId=' + clientId); request.setMethod('GET'); request.setHeader('Content-Type', 'application/json;charset=UTF-8'); request.setHeader('api_key', 'xxxx'); request.setHeader('api_token', 'xxxx'); HttpResponse response = http.send(request); // If the request is successful, parse the JSON response. if (response.getStatusCode() == 200 & response.getbody() != null & response.getbody() != '{}') { // Deserialize the JSON string into collections Map<String, Object> result = (Map<String, Object>) JSON.deserializeUntyped(response.getBody()); system.debug('result ' + result); } else{ system.debug('Error making the callout'); } return null; } }
The result variable looks like this:
{clients=({Customer_FolderId=3, Customer_Secondary_FolderId=0, Customer_WorkflowId=31, Name=Whatever}
I'm stuck here !
Requirement is to connect to this API sending it a clientId and if the client ID exists store the client as a Contact in SF.
Any help would be much apreaciated
Try the suggestions as mentioned in the below blog,
https://salesforce.stackexchange.com/questions/20811/how-to-add-contacts-in-salesforce-via-rest-api
https://developer.salesforce.com/forums/?id=906F0000000ApxUIAS
It might help you.
Thanks!
You need to iterate the result for your required token and you can save that in List and perform DML.
Check with following:
https://salesforce.stackexchange.com/questions/201878/how-to-iterate-over-json
https://salesforce.stackexchange.com/questions/127467/how-to-deserialize-array-of-json-objects-to-an-apex-map
Share your thoughts!
Thanks,
Sucharita