Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform Salesforce数据流到google cloud bigQuery表_Google Cloud Platform_Salesforce_Streaming - Fatal编程技术网

Google cloud platform Salesforce数据流到google cloud bigQuery表

Google cloud platform Salesforce数据流到google cloud bigQuery表,google-cloud-platform,salesforce,streaming,Google Cloud Platform,Salesforce,Streaming,我正在尝试使用PosttoGoogleCloud做一个APEX触发器调用。我遇到的问题是:无论何时触发,我都可以看到身份验证正常进行,但消息仅来自Stackdriver日志,因此云函数将失败,因为消息应为JSON格式。不知道为什么会这样。我对Salesforce是个新手。请提供一些提示 如果我直接测试云函数(使用云函数内部的测试选项),我会像预期的那样看到insert to BigQuery表,但是从Salesforce触发器看来,消息没有被正确捕获。Salesforce中使用的PFB代码。需要

我正在尝试使用PosttoGoogleCloud做一个APEX触发器调用。我遇到的问题是:无论何时触发,我都可以看到身份验证正常进行,但消息仅来自Stackdriver日志,因此云函数将失败,因为消息应为JSON格式。不知道为什么会这样。我对Salesforce是个新手。请提供一些提示

如果我直接测试云函数(使用云函数内部的测试选项),我会像预期的那样看到insert to BigQuery表,但是从Salesforce触发器看来,消息没有被正确捕获。Salesforce中使用的PFB代码。需要与我们插入Salesforce中LEAD表中的Rest API请求相同的消息

销售人员类别:

Public class Callout {
  @future(callout=true)
  Public static void httpcallout(){
    Lead c = [Select Name from Lead Limit 1] ;
    system.debug('Halo Trigger');
    JSONGenerator gen = JSON.createGenerator(true);   
    gen.writeStartObject();     
    gen.writeStringField('Name', c.Name);
    gen.writeEndObject();   
    String jsonS = gen.getAsString();
    System.debug('jsonMaterials'+jsonS);
    String endpoint = 'https://us-central1-valid-weaver- 235212.cloudfunctions.net/Salesforce-GCP';
    HttpRequest req = new HttpRequest();
    req.setEndpoint(endpoint);
    req.setMethod('POST');
    req.setbody(jsonS);
    Http http = new Http();
    HTTPResponse response = http.send(req);
  }
} 
销售人员触发器

trigger SFGCP on Lead (after insert) {
  callout.httpcallout();
  system.debug('Hello');
}
从Salesforce调试

Lead c = new Lead(Company ='Test',LastName='Admin');
insert c;

下面的代码可以很好地工作,只是对云函数做了一些小的修改。谢谢

Public class Callout {
    @future(callout=true)
    Public static void httpcallout()
    {
        Lead c = [select Name, LeadSource, Company from Lead order by createdDate DESC limit 1] ;
        system.debug('Halo Trigger');
        JSONGenerator gen = JSON.createGenerator(true);   
        gen.writeStartObject();     
        gen.writeStringField('Name', c.Name);
        gen.writeStringField('LeadSource', c.LeadSource);
        gen.writeStringField('Company', c.Company);
        gen.writeEndObject();   
        String jsonS = gen.getAsString();
        System.debug('jsonMaterials'+jsonS);
        String endpoint = 'https://us-central1-valid-weaver-235212.cloudfunctions.net    /Salesforce-GCP';
        HttpRequest req = new HttpRequest();
        req.setEndpoint(endpoint);
        req.setMethod('POST');
        req.setbody(jsonS);
        Http http = new Http();
        HTTPResponse response = http.send(req);
    }
}

下面的代码可以很好地工作,只是对云函数做了一些小的修改。谢谢

Public class Callout {
    @future(callout=true)
    Public static void httpcallout()
    {
        Lead c = [select Name, LeadSource, Company from Lead order by createdDate DESC limit 1] ;
        system.debug('Halo Trigger');
        JSONGenerator gen = JSON.createGenerator(true);   
        gen.writeStartObject();     
        gen.writeStringField('Name', c.Name);
        gen.writeStringField('LeadSource', c.LeadSource);
        gen.writeStringField('Company', c.Company);
        gen.writeEndObject();   
        String jsonS = gen.getAsString();
        System.debug('jsonMaterials'+jsonS);
        String endpoint = 'https://us-central1-valid-weaver-235212.cloudfunctions.net    /Salesforce-GCP';
        HttpRequest req = new HttpRequest();
        req.setEndpoint(endpoint);
        req.setMethod('POST');
        req.setbody(jsonS);
        Http http = new Http();
        HTTPResponse response = http.send(req);
    }
}