i have get the sign transaction hash, then, i send RPC request(/injection/operation) like this to brocast operation, this is my junit test, but it return 415 not support media type, i guess because of the requestBody must send a str, but it not a json, but i tried to change the content-type, it not in used.
1 Answer
Have a look at TezosJ_SDK/TezosGateway.java (query method).
MediaType MEDIA_PLAIN_TEXT_JSON = MediaType.parse("application/json");
String s = "a3...";
RequestBody body = RequestBody.create(MEDIA_PLAIN_TEXT_JSON, s.getBytes());
Request request = new Request.Builder()
.url("http://...")
.addHeader("Content-Type", "text/plain")
.post(body)
.build();
OkHttpClient client = new OkHttpClient.Builder().build();
try {
Response response = client.newCall(request).execute();
String strResponse = response.body().string();
} catch ...
-
thanks a lot for help me to deal the problem, i follow your sugestion to update my code, but it return me a new http status 400, message is "bad request", there is my code: Apr 27, 2022 at 2:02
-
my code is very similar with your code, why return a 400 bad request Apr 27, 2022 at 2:07
-
The operation bytes need to be valid ("a3...." is not valid, I just used it as a placeholder). Usually, the 400 status returns some details about what is wrong. Apr 27, 2022 at 6:19
-
i got the reason why return 400, because the rawTransaction hash need surround with " to send in requestBody, i have never see this type of send requestBody, it is amazing Apr 27, 2022 at 9:13
-
Content-Type
.