Community discussions

 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 23946
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: POST Request with fetch

Thu Feb 28, 2019 11:10 am

Your http-data doesn't look like JSON at all, you only have quotes in there.
No answer to your question? How to write posts
 
Cliff
just joined
Posts: 9
Joined: Fri Jul 05, 2013 1:57 am

Re: POST Request with fetch

Thu Feb 28, 2019 11:28 am

My bad, forgot { }. Thanks.
 
WeWiNet
Member Candidate
Member Candidate
Posts: 140
Joined: Thu Sep 27, 2018 4:11 pm

Re: POST Request with fetch

Thu Feb 28, 2019 3:10 pm

Hi jumping on this thread.

I cannot get to the Webhook/IFTTT with the indicated command by Normis:

/tool fetch mode=https url="https://maker.ifttt.com/use/xvcvvxvvcvvxvxvxvv" http-method=post


It gives me error:
status: failed
failure: closing connection: <404 Not Found>

Also tried with additional user info usr=... but same result

What would be the correct syntax to trigger an IFTTT event in IFTTT/Webhooks?

Thanks in advance
---
ROS: 6.44 on RB4011
WeWiNet

**
MTCNA
hapac2, map, hap-lite, ltap-mini, RB4011 :-) !!!
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 23946
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: POST Request with fetch

Thu Feb 28, 2019 3:19 pm

You probably need a different URL, log into IFTTT and visit this page:
https://ifttt.com/maker_webhooks

After logged in and connected, you should see. the Documentation button on the top, it will give you your URL and API KEY
No answer to your question? How to write posts
 
WeWiNet
Member Candidate
Member Candidate
Posts: 140
Joined: Thu Sep 27, 2018 4:11 pm

Re: POST Request with fetch

Thu Feb 28, 2019 4:45 pm

Normis,

this is just a key replacement for the real value I have put there.
The Webhook link itself is correct. just copied it again from IFTTT.

Do you need user name or some other setting?

thanks for your help.
WeWiNet

**
MTCNA
hapac2, map, hap-lite, ltap-mini, RB4011 :-) !!!
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 23946
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: POST Request with fetch

Thu Feb 28, 2019 4:58 pm

No, it should be enough with that link
No answer to your question? How to write posts
 
WeWiNet
Member Candidate
Member Candidate
Posts: 140
Joined: Thu Sep 27, 2018 4:11 pm

Re: POST Request with fetch

Fri Mar 01, 2019 10:07 am

Thanks Normis, your comment made me continue till I found the issue!

To share with others here the full guide to do IFTTT with RouterOS on Mikrotik:
  • head over to IFTTT and sign up
  • add as service "Webhooks" and go to Webhooks --> settings
    this will give you something like:
    • Connected as: YourGoogleName (you will not need this later on)
    • URL: https://maker.ifttt.com/use/your-code

Now comes the simple, yet tricky thing I missed earlier!!!
  • You need to FOLLOW ABOVE URL (enter it into web browser), to set up the real https link to be used to trigger IFTTT
  • You will see an easy config example with an empty field to be filled by you with YOUR-EVENT-TAG:
    https://maker.ifttt.com/trigger/YOUR-EVENT-TAG/with/key/your-code
    at the same time you can add JSON data in the value fields (not needed to do simple IFTTT trigger.
    You will also see a CURL... example at the bottom, which you can directly run in Linux or on MacOS to trigger the event.
    When finished setting up the TAG copy the new complete https link.
  • In routeros you now can use following command to trigger IFTTT (can then be used in script etc.)
    /tool fetch https://maker.ifttt.com/trigger/YOUR-EVENT-TAG/with/key/your-code keep-result=no
    If successful you will see no error :-) (the data transfert is 0, but this is normal as no data is send).

  • in Your IFTTT applet / recipe you can now use the YOUR-EVENT-TAG to trigger something else...

Hope this helps others


Needless to say, this will only work if google servers are reachable (mikrotik connected to internet) and no firewall rule prevents https traffic

PS: Sorry for the horrible formatting, I have no clue how to use forum editing features. If one has a good guide I am happy to take it...
WeWiNet

**
MTCNA
hapac2, map, hap-lite, ltap-mini, RB4011 :-) !!!
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 23946
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: POST Request with fetch

Fri Mar 01, 2019 10:55 am

Thanks for sharing the full guide, it will be useful to others who want to use IFTTT
No answer to your question? How to write posts
 
User avatar
колбаскин
newbie
Posts: 37
Joined: Tue Mar 29, 2016 6:36 pm
Location: Ukraine Zaporozhye
Contact:

Re: POST Request with fetch

Fri Mar 01, 2019 10:56 am

http-header-field= - allows you to specify only once.
How to specify 3 headers?

-H "X-Auth-Email: max@hd.zp.ua" \
-H "X-Auth-Key: 1c2c585915534145fecded4526e8668177a33" \
-H "Content-Type: application/json" \
Yes, currently only one. We will make multiple possible, check one of the new betas after New Year.
How about this?
Кое что для Mikrotik | hd.zp.ua - Запорожье ITшное.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 23946
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: POST Request with fetch

Fri Mar 01, 2019 11:03 am

Multiple headers already possible for a few versions, even documented in Wiki:
https://wiki.mikrotik.com/wiki/Manual:T ... Properties

It's also discussed in this topic:
viewtopic.php?f=9&t=120860&p=709811&hil ... rs#p717584
No answer to your question? How to write posts
 
ivanfm
newbie
Posts: 41
Joined: Sun May 20, 2012 5:07 pm

Re: POST Request with fetch

Fri Mar 01, 2019 4:18 pm

This things will be better when authentications like digest is implemented for fetch command because some new devices are not supporting more the basic authentication.
 
WeWiNet
Member Candidate
Member Candidate
Posts: 140
Joined: Thu Sep 27, 2018 4:11 pm

Re: POST Request with fetch

Tue Mar 05, 2019 4:08 pm

Normis,

I tried to get the 3 values posted from routerOS into IFTTT without success.
And all the application/json examples are pre 6.44 so I am lost after trying lot of options.
Same for WIKI, still using the http-content-type option which is no more available in 6.44.

The working CURL code from IFTTT is

Code: Select all

curl -X POST -H "Content-Type: application/json" -d '{"value1":"RB4100","value2":"Shutdown","value3":"DSL"}' https://maker.ifttt.com/trigger/mtik/with/key/my_IFTTT_code
--> gives perfect result

The RouterOS command I use based on this (and tried tons of other variants) is:

Code: Select all

/tool fetch https://maker.ifttt.com/trigger/mtik/with/key/my_IFTTT_code keep-result=no
http-header-field=http-content-type:application/json http-data="{\"value1\":\"RB4011\",\"value2\":\"shutting down\",\"value3\":\"DSL"}"
I get the trigger in IFTTT but all my tests show empty values in IFTTT except if I run the CURL command above.
Any advice?

thanks
WeWiNet

**
MTCNA
hapac2, map, hap-lite, ltap-mini, RB4011 :-) !!!
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5839
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: POST Request with fetch

Tue Mar 05, 2019 5:06 pm

http-header-field="Content-Type: application/json"
 
WeWiNet
Member Candidate
Member Candidate
Posts: 140
Joined: Thu Sep 27, 2018 4:11 pm

Re: POST Request with fetch

Tue Mar 05, 2019 6:46 pm

Does not work with this command. Puts an error:
/tool fetch https://maker.ifttt.com/trigger/mtik/with/key/my_IFTTT_code keep-result=no \
http-header-field="Content-Type:application/json" \
http-data="{\"value1\":\"RB4011\",\"value2\":\"shutting down\",\"value3\":\"DSL"}"
It spits error out:
status: failed
failure: closing connection: <400 Bad Request> 34.201.148.91:443 (4)
has someone used IFTTT recently with values under with 6.44
WeWiNet

**
MTCNA
hapac2, map, hap-lite, ltap-mini, RB4011 :-) !!!
 
taxist
just joined
Posts: 1
Joined: Thu Mar 14, 2019 6:08 pm

Re: POST Request with fetch

Fri Mar 15, 2019 9:47 am

To owerload content type need use directive http-header-field and set key content-type in lower case, example
http-header-field="content-type:text/plain"
 
WeWiNet
Member Candidate
Member Candidate
Posts: 140
Joined: Thu Sep 27, 2018 4:11 pm

Re: POST Request with fetch

Thu Apr 04, 2019 12:39 pm

Hi taxist,

thanks for your advice, but the IFTTT webhook data does not work neither with this.
The issue is always that either routeros does not accept the syntax that IFTTT would need and gives you an error,
or if you put it in routeros syntax, webhook does not get/display the data.

Do you have a full command example with data that works?
WeWiNet

**
MTCNA
hapac2, map, hap-lite, ltap-mini, RB4011 :-) !!!
 
tempoff
just joined
Posts: 2
Joined: Fri May 10, 2019 1:47 pm

Re: POST Request with fetch

Fri May 10, 2019 1:51 pm

Hello everyone!

Can you also add a patch http method to fetch tool please? It can be very useful.
 
bruna
just joined
Posts: 1
Joined: Thu May 16, 2019 9:14 pm

mikrotik does not recognize intel network card

Fri May 17, 2019 4:02 pm

Hi

mikrotik does not recognize intel network card.



I installed the Mikrotik software on a hardware and after installation Mikrotik does not recognize the network card.

Could someone help?


any alternative?

thanks !

Who is online

Users browsing this forum: No registered users and 5 guests