Skip to Main Content

Embedded Technologies

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to add a JSON object to the body of an HTTP POST request

Bruno LJun 2 2014 — edited Jun 2 2014

Hello,

I am using Java 8 ME Embedded and I would like to add a Json object in the body of an http request.

I would like to do something like :

-----------------------------------------------------------------------------------------

     HttpClientBuilder clientBuilder = HttpClientBuilder.getInstance();

        HttpClient client = clientBuilder.build();

        HttpRequestBuilder requestBuilder = client.build("my_URI");
        requestBuilder.setHeader(HttpHeader.ACCEPT, "text/plain");

[...]

        requestBuilder.setMethod(HttpMethod.POST);


        HttpRequest request = requestBuilder.build();

//creating the Json object to be sent in the http request body
      JsonObject myJsonObj= Json.createObjectBuilder()
     .add("firstname", "John")
     .add("lastname", "XXX")
     .build();

//This part, I am a bit confused : how to get the OutputStream in which I should put the Json object?

JsonWriter jsonWriter = Json.createWriter(java.io.OutputStream out);

jsonWriter.writeObject(myJsonObj);

jsonWriter.close();

     //invoking the http request

      HttpResponse response = request.invoke();

-----------------------------------------------------------------------------------------

Do you have any tip, please ?
Thanks in advance.

Bruno

This post has been answered by Sergey.N-Oracle on Jun 2 2014
Jump to Answer

Comments

Jim Smith

SQL Developer doesn't put anything in the registry.
From your reference to SID, I assume you are looking for a database. SQL Developer is only a client tool, it doesn't come with a database.
You will need to download and install the database software as well. The easiest thing to do is to download express edition
Oracle Database Express Edition (XE) Downloads (0 Bytes)

What Jim said, we don't have an installer, we don't put anything into the registry.
I think we'll check the registry for an Oracle Client/HOME, but we write all of our application settings to your AppData folder, under Roaming Profiles.

1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 30 2014
Added on Jun 2 2014
4 comments
7,462 views