• Bujji v
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies

Hi,

 

I have a doubt I am getting HTTP post request from campaign monitor to my salesfroce URL in the form of JSON.

I got this message in my debug log

 

Accept-Encoding=gzip, deflate, Cache-Control=no-cache, no-store, max-age=259200, Connection=keep-alive, Content-Length=201, Content-Type=application/json

 

 

 

when i used ApexPages.currentPage().getHeaders();

 

 

Now I need to retrive the JSON data, anyone please help me...

 

 

Thanks in advance.

Hi,

I have a doubt in webhooks integration. I have created a webhook between campaign monitor and salesforce using salesforce site URL. According to campaign monitor webhooks concept they will POST a HTTP request in the format of JSON when any of the campaign monitor subscriber changes his state, and I am able to get the request in salesforce debug Log, But I am unable to read that JSON data.

 

My site have a class to read that HTTP Post request which is coming from campaign monitor but in that I am getting status code 400. My class is

 

public class HttpCalloutSample2 {

  public String getContent() {

    Http h = new Http();

    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://MYSITEURL/");
    req.setMethod('GET');
    req.setHeader('Content-Length', '');
    system.debug('request:'+req.getBody());
    HttpResponse res = h.send(req);
    return res.getBody();
  }
}

 

I have given this class to public access and called this class in site's home page as controller.

 

 

Please Help me in this issue.

Hi,

 I want to create Webhook for Campaign Monitor. I just gone through http://www.campaignmonitor.com/api/webhooks/....

In that I found, we have to mention an URL in JSON body to create a Webhook. For that what is the URL I have to specify.

 

 

When I am trying to update a field by using @future method. It was showing an error message like " Future method cannot be called from a future or batch method " .

Here is my code...

 

My trigger is

 

trigger test on Contact (before insert,before update) {

for (Contact contact : Trigger.new) {

 

        string endPoint;      
        endPoint = ''https://test.com/body.json';
        Webcooks.GetRequest(endPoint,contact.LastName,contact.email);

        string endPoint2;      
        endPoint2 = ''https://test.com/response.json?email=';
        Webcooksstatus.GetRequest(endPoint,contact.LastName,contact.email);
        contact.Campaign_Monitor_Status__c = '';
        Webcooksstatus.test();

}

 

}

 

 

 

My class is...

 

Public class Webcooks
{
@future(callout=true)
public static void GetRequest(String url,string LastName,string email)
{


HttpRequest con = new HttpRequest();

con.setBody('{"EmailAddress": "'+email+'","Name": "'+LastName+'"}');
String username = 'dfsfsdffsfsa';
String password = '';

 

Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'BASIC ' +
EncodingUtil.base64Encode(headerValue);
con.setHeader('Authorization', authorizationHeader);
con.setEndpoint(url);
con.setMethod('POST');

Http http = new Http();
HTTPResponse res = http.send(con);

}
}

 

My second class is....

 

Public class Webcooksstatus
{

public static string statused{get;set;}
public static string status{get;set;}
public static string state{get;set;}

@future(callout=true)
public static void GetRequest(string url,string LastName,String email)
{
String body='{"EmailAddress": "'+email+'","Name": "'+LastName+'"}';
state = email;
HttpRequest con = new HttpRequest();
con.setMethod('GET');
String username = 'dfsfsdffsfsa';
String password = '';
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'BASIC ' +
EncodingUtil.base64Encode(headerValue);
con.setHeader('Authorization', authorizationHeader);

con.setEndpoint(url+Email);

Http http = new Http();
HTTPResponse res = http.send(con);

JSONParser parser = JSON.createParser(res.getBody());
       
        while (parser.nextToken() != null) {
            if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                (parser.getText() == 'State')) {
                
                parser.nextToken();
               
                status = parser.getText();
               
            }
        }
         statused =status;
}

test();
}

public static void test()
{
list<Contact> ContactsToUpdate =  new List<Contact>();
for (Contact c : [Select Id, Name,Campaign_Monitor_Status__c  From Contact where email=:state]) {

c.Campaign_Monitor_Status__c = statused ;

ContactsToUpdate.add(c);
}
update ContactsToUpdate;

}

}

 

 

I want to update "Campaign_Monitor_Status__c"  field with the "statused".... Please Help me

 

 

 

Hi,

 I want to create Webhook for Campaign Monitor. I just gone through http://www.campaignmonitor.com/api/webhooks/....

In that I found, we have to mention an URL in JSON body to create a Webhook. For that what is the URL I have to specify.

 

 

Hi,

 

I have a doubt I am getting HTTP post request from campaign monitor to my salesfroce URL in the form of JSON.

I got this message in my debug log

 

Accept-Encoding=gzip, deflate, Cache-Control=no-cache, no-store, max-age=259200, Connection=keep-alive, Content-Length=201, Content-Type=application/json

 

 

 

when i used ApexPages.currentPage().getHeaders();

 

 

Now I need to retrive the JSON data, anyone please help me...

 

 

Thanks in advance.

Hi,

I have a doubt in webhooks integration. I have created a webhook between campaign monitor and salesforce using salesforce site URL. According to campaign monitor webhooks concept they will POST a HTTP request in the format of JSON when any of the campaign monitor subscriber changes his state, and I am able to get the request in salesforce debug Log, But I am unable to read that JSON data.

 

My site have a class to read that HTTP Post request which is coming from campaign monitor but in that I am getting status code 400. My class is

 

public class HttpCalloutSample2 {

  public String getContent() {

    Http h = new Http();

    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://MYSITEURL/");
    req.setMethod('GET');
    req.setHeader('Content-Length', '');
    system.debug('request:'+req.getBody());
    HttpResponse res = h.send(req);
    return res.getBody();
  }
}

 

I have given this class to public access and called this class in site's home page as controller.

 

 

Please Help me in this issue.

When I am trying to update a field by using @future method. It was showing an error message like " Future method cannot be called from a future or batch method " .

Here is my code...

 

My trigger is

 

trigger test on Contact (before insert,before update) {

for (Contact contact : Trigger.new) {

 

        string endPoint;      
        endPoint = ''https://test.com/body.json';
        Webcooks.GetRequest(endPoint,contact.LastName,contact.email);

        string endPoint2;      
        endPoint2 = ''https://test.com/response.json?email=';
        Webcooksstatus.GetRequest(endPoint,contact.LastName,contact.email);
        contact.Campaign_Monitor_Status__c = '';
        Webcooksstatus.test();

}

 

}

 

 

 

My class is...

 

Public class Webcooks
{
@future(callout=true)
public static void GetRequest(String url,string LastName,string email)
{


HttpRequest con = new HttpRequest();

con.setBody('{"EmailAddress": "'+email+'","Name": "'+LastName+'"}');
String username = 'dfsfsdffsfsa';
String password = '';

 

Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'BASIC ' +
EncodingUtil.base64Encode(headerValue);
con.setHeader('Authorization', authorizationHeader);
con.setEndpoint(url);
con.setMethod('POST');

Http http = new Http();
HTTPResponse res = http.send(con);

}
}

 

My second class is....

 

Public class Webcooksstatus
{

public static string statused{get;set;}
public static string status{get;set;}
public static string state{get;set;}

@future(callout=true)
public static void GetRequest(string url,string LastName,String email)
{
String body='{"EmailAddress": "'+email+'","Name": "'+LastName+'"}';
state = email;
HttpRequest con = new HttpRequest();
con.setMethod('GET');
String username = 'dfsfsdffsfsa';
String password = '';
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'BASIC ' +
EncodingUtil.base64Encode(headerValue);
con.setHeader('Authorization', authorizationHeader);

con.setEndpoint(url+Email);

Http http = new Http();
HTTPResponse res = http.send(con);

JSONParser parser = JSON.createParser(res.getBody());
       
        while (parser.nextToken() != null) {
            if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                (parser.getText() == 'State')) {
                
                parser.nextToken();
               
                status = parser.getText();
               
            }
        }
         statused =status;
}

test();
}

public static void test()
{
list<Contact> ContactsToUpdate =  new List<Contact>();
for (Contact c : [Select Id, Name,Campaign_Monitor_Status__c  From Contact where email=:state]) {

c.Campaign_Monitor_Status__c = statused ;

ContactsToUpdate.add(c);
}
update ContactsToUpdate;

}

}

 

 

I want to update "Campaign_Monitor_Status__c"  field with the "statused".... Please Help me