HTTPClient PostMethod for byte []

I need to send byte [] to save the endpoint of the web service, and I was wondering how to configure the request using HTTPClient PostMethod, any ideas?

+6
source share
1 answer

ByteArrayEntity should be what you are looking for:

[...] PostMethod post = new PostMethod(url); post.setRequestEntity(new ByteArrayEntity(bytes)); post.setRequestHeader("Content-type", "application/octet-stream"); [...] 

You need to set the content-type to match what you have in the byte array.

+8
source

Source: https://habr.com/ru/post/886764/


All Articles