BeckhoffHttpClient icon indicating copy to clipboard operation
BeckhoffHttpClient copied to clipboard

POST application/octet-stream [Binary image data]...

Open runtimevic opened this issue 3 years ago • 9 comments

Hello @fbarresi , I want to create a POST but the request body asks me for an application/octet-stream [Binary image data], I attached a photo so you can see how can i do it?

body_request

Thank you very much for everything, Victor.

runtimevic avatar Apr 18 '22 20:04 runtimevic

Dear Victor,

The client sadly doesn't cover this scenario. If you give a look into the code you will seen, that the request body is set to text/json always bei default.

Basically I think that could be an interesting enhancement of the http client: the ability to change the content type or to upload a stream.

Would you help to generalize this problem in order to create a new feature for this client?

Probably another valid (quick and dirty) way to reach your goal would be a simple modification for your specific case or your own function for doing specific stuff. Of course, if your would like to go this way, feel free to fork this repo and use it as backbone.

Best regards, Fede

fbarresi avatar Apr 18 '22 20:04 fbarresi

Dear Victor,

The client sadly doesn't cover this scenario. If you give a look into the code you will seen, that the request body is set to text/json always bei default.

Basically I think that could be an interesting enhancement of the http client: the ability to change the content type or to upload a stream.

Would you help to generalize this problem in order to create a new feature for this client?

Probably another valid (quick and dirty) way to reach your goal would be a simple modification for your specific case or your own function for doing specific stuff. Of course, if your would like to go this way, feel free to fork this repo and use it as backbone.

Best regards, Fede

Hello @fbarresi , I would like to be able to do it, but I think it exceeds my knowledge at the moment to carry it out, I don't know if it's too much work for you to add it as a new functionality?? Best regards, Víctor

runtimevic avatar Apr 19 '22 16:04 runtimevic

Dear Victor,

I think it depends on the request. I still didn't understand how this request looks like in your case. I know how form-data or octect stream are sent, but how do you think you have this kind of data in your plc? (in form of bytes array or a file?) Please, let me know.

Best regards, Fede

fbarresi avatar Apr 20 '22 07:04 fbarresi

Dear Victor,

I think it depends on the request. I still didn't understand how this request looks like in your case. I know how form-data or octect stream are sent, but how do you think you have this kind of data in your plc? (in form of bytes array or a file?) Please, let me know.

Best regards, Fede

Hi @fbarresi , In the plc I indicate a route where the photo is located... Best regards, Víctor.

runtimevic avatar Apr 20 '22 07:04 runtimevic

What do you mean with a route? Do you mean a file location for a picture?

fbarresi avatar Apr 20 '22 08:04 fbarresi

What do you mean with a route? Do you mean a file location for a picture?

hi @fbarresi , Yes, if it is a file location for a picture... Best regards, Víctor.

runtimevic avatar Apr 20 '22 08:04 runtimevic

Hello, how do you see it? Best regards, Víctor.

runtimevic avatar Apr 26 '22 07:04 runtimevic

Hi! Please apologize my late answer.

In my opinion, this is a case where you don't really need a special Function Software for using this API. As far I understood, you just use some string parameters from the PLC, so basically you were able to cover this case using CURL. Using curl from the PLC is very easy and you don't need any further programming knowledge. Give a look into the Client Library, you will see it just uses FB_GetLocalAmsNetId that allow you to call a software from inside the operating system. After having installed CURL in your target system you can use it over this FB from the PLC.

How does it sound?

Let me know what you think about this solution.

Best regards, FB

fbarresi avatar May 06 '22 06:05 fbarresi

Hi! Please apologize my late answer.

In my opinion, this is a case where you don't really need a special Function Software for using this API. As far I understood, you just use some string parameters from the PLC, so basically you were able to cover this case using CURL. Using curl from the PLC is very easy and you don't need any further programming knowledge. Give a look into the Client Library, you will see it just uses FB_GetLocalAmsNetId that allow you to call a software from inside the operating system. After having installed CURL in your target system you can use it over this FB from the PLC.

How does it sound?

Let me know what you think about this solution.

Best regards, FB

Hi @fbarresi, right now as I have it, it is by launching from Twincat a program in VBScript and this is able to read and write variables on the PLC Twincat and also perform the HTTPS API Rest, my goal was to try to do without vbscript and thus have everything centralized In the Twincat program itself, as I cannot do it through the HTTPS API Rest Beckhoff library function, I have tried to do it with what you have developed ..., I would like to be able to modify your work and contribute but I do not have so many knowledge to do it ...

runtimevic avatar May 06 '22 19:05 runtimevic