Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
runtimevic opened this issue Apr 18, 2022 · 9 comments
Open

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

runtimevic opened this issue Apr 18, 2022 · 9 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers question Further information is requested

Comments

@runtimevic
Copy link

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.

@fbarresi
Copy link
Owner

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

@runtimevic
Copy link
Author

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

@fbarresi
Copy link
Owner

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 fbarresi self-assigned this Apr 20, 2022
@fbarresi fbarresi added enhancement New feature or request good first issue Good for newcomers question Further information is requested labels Apr 20, 2022
@runtimevic
Copy link
Author

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.

@fbarresi
Copy link
Owner

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

@runtimevic
Copy link
Author

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
Copy link
Author

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

@fbarresi
Copy link
Owner

fbarresi commented May 6, 2022

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

@runtimevic
Copy link
Author

runtimevic commented May 6, 2022

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 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants