Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8284071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:57:54+00:00 2026-06-08T10:57:54+00:00

Hi i write a basic web service in apex on salesforce.com plateform here is

  • 0

Hi i write a basic web service in apex on salesforce.com plateform here is apex code

@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;

}


}

and i am trying to send a post request to this service using android
first i authorize it and then get access token and refresh token and after that i again get access_token so there is no problem in access token.here is code for android client

  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);

in output response in Logcat for Hello World i am getting “” as output please point me why i am not getting correct output.i am expecting
[{type:QwikScore_Question_Answer__c ,id:a03900000034MfA ,field:{id:Answer_Text__c,value:1.0}}]
as output because i send
st.write(jsonbody.getBytes());
jsonbody as body of the request.please help me how to get correct output??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:57:56+00:00Added an answer on June 8, 2026 at 10:57 am

    In your request you never set the content-type header, so the server doesn’t know how to parse the payload.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is code I use to POST into RESTful web service. My problem is
I'm tring to write a basic listener for kernel.request event in Symfony 2. Service
Goal: Provide a web service using Visual Basic or C# or .NET that interacts
I'm trying to write a web service client in c# which the webservice is
I'm working with a REST web service that uses basic authentication and returns me
If I want to write a web service and expose it as both WCF
I'm trying to do a very basic http POST to a web service from
I have created a very basic service operation that needs to write content to
I'm trying to write basic assert test: def assert_session_has ( sessionvar ) return assert_not_nil
I wanted to write something basic in assembly under Windows. I'm using NASM, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.