Skip to content
This repository was archived by the owner on Sep 14, 2022. It is now read-only.

Commit 5d01001

Browse files
lukaszx0Bogdan Drutu
authored andcommitted
Attach jsonRequest payload to http request body (#86)
The `jsonRequest` is never attached to the request - every call fails with `411 Length Required`.
1 parent 1a4fa7c commit 5d01001

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sinks/v1/http-consumer/src/main/java/com/google/cloud/trace/http/v1/HttpTraceConsumer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.google.protobuf.InvalidProtocolBufferException;
2222
import com.google.protobuf.util.JsonFormat;
2323
import java.io.IOException;
24+
import java.io.OutputStream;
2425
import java.io.InputStream;
2526
import java.net.HttpURLConnection;
2627
import java.net.MalformedURLException;
@@ -76,6 +77,10 @@ private void processTraces(Traces traces, String projectId) {
7677
connection.setRequestProperty("Content-Type", "application/json");
7778
connection.setRequestProperty(
7879
"Authorization", "Bearer " + oAuth2Credentials.getAccessToken().getTokenValue());
80+
connection.setDoOutput(true);
81+
OutputStream out = connection.getOutputStream();
82+
out.write(jsonRequest.getBytes());
83+
out.close();
7984
// Use the connection to make the request. This also sets the connection's response code.
8085
InputStream responseStream = connection.getInputStream();
8186
int responseCode = connection.getResponseCode();

0 commit comments

Comments
 (0)