首页 > 解决方案 > 将 Zendesk 票发送给 salesforce

问题描述

我想将 Zendesk 票发送到 Salesforce。我在 zendesk 的扩展中使用了 http 目标选项,并设置了我的 visualforce 页面的 url(Url:https ://c.ap4.visual.force.com/apex/restOutput ),还启用了基本身份验证。当我从 zendesk 发送测试数据时,Salesforce 开发人员控制台中不会生成任何日志。zendesk 发送测试数据后的响应。

`

HTTP/1.1 200 OK
Date: Tue, 31 Jul 2018 04:53:09 GMT
Public-Key-Pins-Report-Only: pin-sha256="9n0izTnSRF+W4W4JTq51avSXkWhQB8duS2bxVLfzXsY="; pin-sha256="5kJvNEMw0KjrCAu7eXY5HZdvyCS13BbA0VJG1RSP91w="; pin-sha256="njN4rRG+22dNXAi+yb8e3UMypgzPUPHlv4+foULwl1g="; max-age=86400; includeSubDomains; report-uri="https://calm-dawn-26291.herokuapp.com/hpkp-report/nullm";
Expect-CT: max-age=0; report-uri="https://calm-dawn-26291.herokuapp.com/Expect-CT-report/nullm";
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: upgrade-insecure-requests 
X-Robots-Tag: none
Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private
Set-Cookie: BrowserId=EKk-yAZfRfOSD0AHf2etLA;Path=/;Domain=.force.com;Expires=Sat, 29-Sep-2018 04:53:09 GMT;Max-Age=5184000
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding
Content-Encoding: gzip
Transfer-Encoding: chunked
Connection: close
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head></head><body onload="document.forms['workerForm'].submit()">
<form  accept-charset="UTF-8" action="https://ap4.salesforce.com/visualforce/session" enctype="application/x-www-form-urlencoded" id="workerForm" method="post" name="workerForm" ><input type="hidden" name="url" id="url" value="https://c.ap4.visual.force.com/apex/restOutput" />
</form>
</body>
</html>

`

我的可视化页面代码如下:`

<apex:page controller="myController">
</apex:page>

`

我的控制器定义为

`

@RestResource(urlMapping='/restOutput')
global class myController {
    public myController(){
        System.debug('constructor');
       callBack();
    }
    @HttpPost
    global static void callBack()
    {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        System.debug(req.requestBody);
        //System.debug(ApexPages.currentPage().getParameters());
    }
}

`

标签: salesforcewebhooksapexzendesk

解决方案


最后我得到了解决方案,我在使用 api 时犯了错误。要使用 Salesforce api,请发送带有授权标头(包含访问令牌)的发布请求,发布数据。请求似乎类似于。

  curl --request POST \
  --url https://ap4.lightning.force.com/services/apexrest/restOutput \
  --header '<access_token or sessionID' \
  --data '{\n"ticket_title":"Workbench Api Request Test",\n"ticket_description":"This is just a test Description",\n"ticket_status":"New",\n"requester_firstname":"Ebizon",\n"requester_lastname":"NetInfo",\n"requester_email":"contact@ebizontek.com"\n}\n' 

推荐阅读