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的主体如何获得正确的输出?