fbarresi / BeckhoffHttpClient

Unofficial TwinCAT function for HTTP-Client and Json conversion

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

body not valid for post request

swillemsACCIO opened this issue · comments

commented

I have a post request to Telegram:
Invoke-RestMethod -Uri https://api.telegram.org/botTTT/sendMessage -Method 'POST' -ContentType 'applicatiomn/json' -Body '{"chat_id": "12345", "text": "This is a test from curl", "disable_notification": true}'
The json Object in the PLC is like that:
TYPE Json_Telegram :
STRUCT
{attribute 'json' := 'chat_id'}
chat_id : STRING := '1020187857';
//iResponse : INT;
{attribute 'json' := 'text'}
text : STRING := 'ScreenCut';
END_STRUCT
END_TYPE
I think, the content-type text/json is not ok, but it comes directly from you program.
Any suggestions?

BTW: Great work! This is a very nice and useful application!

commented

I solved this issue by changing the content-type to application/json inside the C# program TFU001.
I would like to suggest to set the content-type inside the header-file and eliminate the fixed content-type inside the C# program.
Have fun!

Hi!

Thank you for reporting this issue, I will fix it as soon as possible.
Using a file for such additional settings is good idea, I'm also evaluating an optional flag, that can also be controlled by the plc.
Best regards,
FB