3

営業部門で Fluid Survey API にアクセスしようとしています。次のコードを使用しますが、エラーで応答します。

コントローラ クラスのコードは次のとおりです。

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:password@app.fluidsurveys.com/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: "password@app.fluidsurveys.com"
Error is in expression '{!chk}' in component <apex:page> in page fluid-page
4

2 に答える 2