我试图访问Salesforce中的流体调查API。我使用下面的代码,但它响应一个错误。System.CalloutException:对于输入字符串:“[email protected]”
的控制器类的代码是:
public class fluidSurvey{
public String tst{set;get;}
public String result{get;set;}
public PageReference chk() {
//if (!ApexPages.hasMessages())
result=getData();
return null;
}
public String getData()
{
HttpRequest req= new HttpRequest();
Http http = new Http();
req.setMethod('GET');
String url = 'https://username:[email protected]/api/v2/surveys/';
req.setEndpoint(url);
HttpResponse res = http.send(req);
String json = res.getBody().replace('\n','');
tst = json;
try {
JSONObject j = new JSONObject(json);
return parseJson(j);
} catch (JSONObject.JSONException e) {
return 'Error parsing JSON response from Google: '+e;
}
}
public String parseJson(JSONObject resp){
String detail =resp.getString('total');
return detail;
}
}
和顶点页面的代码是:
<apex:page controller="fluidSurvey">
<!-- Begin Default Content REMOVE THIS -->
<h1>Fluid Survey</h1>
<apex:form >
<apex:outputText value="{!tst}"></apex:outputText>
<apex:commandButton value="Submit" action="{!chk}"/>
</apex:form>
</apex:page>
但是当我点击提交按钮就创建了以下错误:
System.CalloutException: For input string: "[email protected]"
Error is in expression '{!chk}' in component <apex:page> in page fluid-page
您已经添加了“fluidsurveys.com”到(代码允许将消息发送到端点)远程站点的列表?你可以在安装程序搜索中找到它。 – eyescream
是的,我为它创建了一个远程站点 – WiXXeY
您可以请发布调试输出吗? –