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

  • Home
  • SEARCH
  • 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 7747213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:28:25+00:00 2026-06-01T10:28:25+00:00

I have a very simple scenario which I cannot get to work. I am

  • 0

I have a very simple scenario which I cannot get to work. I am trying to POST a JSON string to a RESTful endoint using cURL to sent the request over HTTPS and RESTeasy on the server.

My cURL POST is configured thusly:

$ch = curl_init();

$content = json_encode($validJsonString);

curl_setopt($ch, CURLOPT_URL, 'https://foobar.com/test?trackingId=12345');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('json' => $content));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);

$headers = array( 
    'Content-Type: application/json',
    'Content-Length: ' . strlen($content)
);

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec ($ch);

$httpResponseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

$json = json_decode($response);
curl_close ($ch);

return $json;

And the RESTeasy recipiant looks like:

@POST
@Path("/test")
@Produces("application/json")
public String addObjectCommentAsJSON(   @FormParam("json") String validJsonString, 
                                        @QueryParam("trackingId") String trackingId) {
    Gson gson = new Gson();
    SomeObject someObject = gson.fromJson(validJsonString, SomeObject.class);
    String responseString = methodThatReturnsAJsonString(trackingId, someObject);
    return responseString;
}

This issue I am having is that the request hangs for about 30 seconds and then returns a HTTP 100 response. I understand that HTTP 100 means continue with the remainder of the request but I don’t understand how I am supposed to do that.

I tried to remove the Content-Length header but obviously I get a 411 (needs content length) so that’s not an option either.

Is it an issue with the content type perhaps? Any help is much appreciated.

  • 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-01T10:28:26+00:00Added an answer on June 1, 2026 at 10:28 am

    Ok so thanks to @cbuckley and @abraham’s suggestions in their comments I have been able to work through the issues. This is what I needed to do:

    1-> Change the contents of the POST body so instead of curl_setopt($ch, CURLOPT_POSTFIELDS, array('json' => $content)); I now have curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($validJsonString));

    2-> I created a custom @Provider which parsed a JSON string to a Java POJO with the same structure:

    @Provider
    public class SomeObjectProvider implements StringConverter<SomeObject> {
    
        private final Gson gson = new Gson();
        public SomeObject fromString(String s) {
            return gson.fromJson(s, SomeObject.class);
        }
    
        public String toString(SomeObject someObject) {
            return gson.toJson(SomeObject);
        } 
    }
    

    3-> Finally the structure of the recipient method has to change slightly:

    @POST
    @Path("/test")
    @Produces("application/json")
    public String addObjectCommentAsJSON(SomeObject someObject,
                                         @QueryParam("trackingId") String trackingId) {
        String responseString = methodThatReturnsAJsonString(trackingId, someObject);
        return responseString;
    }
    

    And that all flowed through nicely.

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

Sidebar

Related Questions

I have a very simple scenario where I want to POST the form using
I have a very simple scenario, using NHibernate: one abstract base class animal; two
I have a very simple scenario: My iPhone application contains a UIViewController implementation which
I have been trying to do a very simple auditing scenario following Ayende's blog
I have a very simple scenario involving a database and a JMS in an
We're currently using Salesforce for our sales process, which involve trying to get people
I have a very simple problem for which though I have a solution but
Given a very simple string[] , I am trying to accomplish the following in
I have very simple window where I have 2 buttons - one for cancel,
I have a very simple webforms app that will allow field techs to order

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.