0
嗨,我在salesforce.com上。平臺寫頂點基本Web服務這裏是頂點代碼RestService沒有給預期的結果
@RestResource(urlMapping='/gggg')
global with sharing class HelloWorld{
@HttpPost
global static String doPut(){
RestRequest req=RestContext.request;
RestResponse res=RestContext.response;
String body1=req.requestBody.toString();
return body1;
}
}
,我試圖用發送POST請求該服務的Android 第一本人授權,然後獲得訪問令牌和刷新令牌之後,我再次得到這樣的access_token中有訪問token.here沒有問題在世界您好我在logcat的輸出響應爲Android客戶端
URL url1=new URL("https://ap1.salesforce.com/services/apexrest/gggg");
HttpURLConnection connection=(HttpURLConnection) url1.openConnection();
connection.addRequestProperty("Authorization", "OAuth "+str);
connection.setRequestMethod("POST");
connection.setDoOutput(true);
String jsonbody="[{type:QwikScore_Question_Answer__c ,id:a03900000034MfA ,field:{id:Answer_Text__c,value:1.0}}]";
OutputStream st=connection.getOutputStream();
st.write(jsonbody.getBytes());
st.close();
connection.connect();
BufferedReader reader=new BufferedReader(new InputStreamReader(connection.getInputStream()));
String ss="";
String ss1="";
while((ss=reader.readLine())!=null){
ss1+=ss;
}
Log.i("Hello world",ss1);
代碼得到「」作爲輸出點我爲什麼我沒有得到正確的輸出。我期待 [{type:QwikScore_Question_Answer__c,id:a03900000034MfA,field:{id:Answer_Text__c,value:1.0}}]作爲輸出,因爲我發送 st.write(jsonbody。的getBytes()); jsonbody作爲request.please的主體如何獲得正確的輸出?