开发者

HTTPClient PostMethod for byte[]

开发者 https://www.devze.com 2023-03-01 03:11 出处:网络
I need to send a byte[] to rest web service end point and I was wondering how to setup the request using HTTPClient\'s PostMethod开发者_开发知识库, any ideas?ByteArrayEntity should be what your\'re lo

I need to send a byte[] to rest web service end point and I was wondering how to setup the request using HTTPClient's PostMethod开发者_开发知识库, any ideas?


ByteArrayEntity should be what your're looking for:

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消