Page 1 of 1
POST Request with fetch
Posted: Wed Apr 19, 2017 5:06 am
by jamecollins
Hi everyone, I want create a script to get information on mikrotik device and post this to my server. I see fetch can create the request but I don't know how to create POST request with this. On the
https://wiki.mikrotik.com/wiki/Manual:Tools/Fetch only tell that fetch can GET. How to create POST request with fetch? Thanks.
Thanks.
Re: POST Request with fetch
Posted: Wed Apr 19, 2017 9:49 am
by normis
You can do it this way:
/tool fetch mode=https url="https://yoursite.com/link/5eu1a1kkypnypbyseqzsq1ao4w" http-method=post http-data="payload={\"text\": \"Test\"}"
This was added in the latest RouterOS 6.39 RC versions
fetch - added "http-data" and "http-method" parameters to allow delete, get, post, put methods (content-type=application/x-www-form-urlencoded by default);
Re: POST Request with fetch
Posted: Wed Apr 19, 2017 10:25 am
by genesispro
is there a way to post an array of values? eg a /find something like dhcp leases
Re: POST Request with fetch
Posted: Wed Apr 19, 2017 12:15 pm
by janisk
the contents should contain data that the other side will understand as an array. You can use a RouterOS script to gather required data on the router.
Re: POST Request with fetch
Posted: Wed Apr 19, 2017 12:45 pm
by ericksetiawan
You can do it this way:
/tool fetch mode=https url="https://yoursite.com/link/5eu1a1kkypnypbyseqzsq1ao4w" http-method=post http-data="payload={\"text\": \"Test\"}"
This was added in the latest RouterOS 6.39 RC versions
fetch - added "http-data" and "http-method" parameters to allow delete, get, post, put methods (content-type=application/x-www-form-urlencoded by default);
Wow, this is awesome. Back before this, I always use email to send encoded status in json.
Re: POST Request with fetch
Posted: Wed Apr 19, 2017 4:08 pm
by normis
yes, now your router can trigger IFTTT, send Slack and Telegram messaged and so much more.
Re: POST Request with fetch
Posted: Sat May 06, 2017 7:24 pm
by lelmus
You can do it this way:
/tool fetch mode=https url="https://yoursite.com/link/5eu1a1kkypnypbyseqzsq1ao4w" http-method=post http-data="payload={\"text\": \"Test\"}"
This was added in the latest RouterOS 6.39 RC versions
fetch - added "http-data" and "http-method" parameters to allow delete, get, post, put methods (content-type=application/x-www-form-urlencoded by default);
Is there any way to change "content-type=application/x-www-form-urlencoded" to "content-type=application/json"??
Re: POST Request with fetch
Posted: Thu May 11, 2017 10:39 am
by jamecollins
You can do it this way:
/tool fetch mode=https url="https://yoursite.com/link/5eu1a1kkypnypbyseqzsq1ao4w" http-method=post http-data="payload={\"text\": \"Test\"}"
This was added in the latest RouterOS 6.39 RC versions
fetch - added "http-data" and "http-method" parameters to allow delete, get, post, put methods (content-type=application/x-www-form-urlencoded by default);
How can I upload file with new fetch feature?
Thanks.
Re: POST Request with fetch
Posted: Thu May 11, 2017 5:52 pm
by chaplin
Is it possible to PUT Content-Type: application/json ? I would want to perform the following but i couldn't.
curl -X PUT "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records/372e67954025e0ba6aaa6d586b9e0b59" \
-H "X-Auth-Email: user@example.com" \
-H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"example.com","content":"127.0.0.1","ttl":120,"proxied":false}'
Re: POST Request with fetch
Posted: Wed Jun 14, 2017 7:06 pm
by jobear
Hi,
adding a content-type for fetch is important and also needed on my end. Most WebServices do require json encoded data and do not accept plain/text.
Re: POST Request with fetch
Posted: Wed Jun 14, 2017 10:09 pm
by andriys
adding a content-type for fetch is important and also needed on my end
You can already do that. Please read the second message in this thread carefully.
Re: POST Request with fetch
Posted: Fri Jun 16, 2017 4:24 pm
by jobear
adding a content-type for fetch is important and also needed on my end
You can already do that. Please read the second message in this thread carefully.
Not sure if i am thinking wrong, yes i can put json data in the http payload as shown in post #2 but the http header still contains "application/x-www-form-urlencoded". In my case the application server evaluates the http header and therefore throws an error.
There should be an additional string option for fetch to change the content-type header in the http-request.
Re: POST Request with fetch
Posted: Mon Jul 03, 2017 8:19 pm
by thantoldo
Can you please raise the 65535 character limit (double it or remove it completely), so that the error case "max line length 65535 exceeded!" is resolved?
It happens both with GET and POST (I understand that could occur with GET, but it shouldn't with POST)
As routerOS is more and more involved in the big data domain, it is imperative that such limitations are removed.
Re: POST Request with fetch
Posted: Mon Jul 10, 2017 1:36 pm
by ADvorkin
How to send header in the method post or get? Option "-H" in curl. For example
curl -H 'PddToken: 123456789ABCDEF0000000000000000000000000000000000000' 'https://pddimp.yandex.ru/api2/admin/dns/list?domain=domain.com'
Re: POST Request with fetch
Posted: Sun Jul 16, 2017 8:21 pm
by LaZyLion
Hi all
This new post feature is great for me.
It adds an extra layer of security and peace of mind when transmitting sensitive information like wifi passwords.
I have a script that all my routers run to check in with my php server. It started as a dyndns client but has evolved into so much more.
Here's my two cents worth:
First on the router:
# gather basic router info -----------------------------------------------
:local uptime [/system resource get uptime];
:local macadd [/interface wireless get [ find default-name=wlan1 ] mac-address]
:local ver [/system resource get version]
:local name [/system identity get name]
# gather wireless info ---------------------------------------------------
:local wifi [/interface wireless get [ find default-name=wlan1 ] ssid]
:local pw [/interface wireless security-profiles get [ find name=default ] wpa2-pre-shared-key]
# put it all together ----------------------------------------------------
:set $str "rtrName=$name&rtrMac=$macadd&rtrUptime=$uptime&rtrVersion=$ver&ssidName=$wifi&ssidKey=$pw";
# send to server ---------------------------------------------------------
:do {
:put "Checking in";
/tool fetch mode=https url="https://domain.com/checkin.php" keep-result=yes dst-path="result.txt" \
user="routerdevice" password="garbledpassword" http-method="post" http-data=$str ;
} on-error={ log warning "Greeter: Send to server Failed!" }
Save it as greeter.rsc, upload it to your routers and have system scheduler 'import' it regularly.
Now on your php server:
//display the received data
print_r($_POST);
// or
foreach ($_POST as $key => $value) {
echo $key . ": " . $value . "<p>\r\n";
}
// Note incoming IP address and timestamp
$checkin_ip = $_SERVER['REMOTE_ADDR'];
$checkin_time = time();
// give a reply
echo "good " . $_SERVER['REMOTE_ADDR'] . "\r\n";
// Now save to a database
Save that as checkin.php and put it where it is reachable on your server.
PHP $_POST expects the same format as the standard http Get:
https://domin.com/checkin.php?rtrName=GrandmasHouse&rtrMac=00:11:22:33:44:55&rtrUptime=01:02:03&ssidName=BigBertha&ssidKey=puppies
Hope this helps somebody out.
LL
Re: POST Request with fetch
Posted: Tue Aug 22, 2017 7:30 am
by Amm0
Found this thread since I wanted to do a POST using /tools fetch...very useful...
But MT should update the docs on it, since http-data etc. isn't mentioned as a parameter:
https://wiki.mikrotik.com/wiki/Manual:Tools/Fetch
Re: POST Request with fetch
Posted: Thu Sep 28, 2017 5:37 pm
by jelyasi
I want to write a script in order to log result of fetch tool , can anyone help me?
Re: POST Request with fetch
Posted: Thu Oct 12, 2017 11:06 am
by jamecollins
You can do it this way:
/tool fetch mode=https url="https://yoursite.com/link/5eu1a1kkypnypbyseqzsq1ao4w" http-method=post http-data="payload={\"text\": \"Test\"}"
This was added in the latest RouterOS 6.39 RC versions
fetch - added "http-data" and "http-method" parameters to allow delete, get, post, put methods (content-type=application/x-www-form-urlencoded by default);
Hi, can I upload a text file using fetch
Re: POST Request with fetch
Posted: Tue Oct 24, 2017 2:48 pm
by Setneuf
Can you please raise the 65535 character limit (double it or remove it completely), so that the error case "max line length 65535 exceeded!" is resolved?
It happens both with GET and POST (I understand that could occur with GET, but it shouldn't with POST)
As routerOS is more and more involved in the big data domain, it is imperative that such limitations are removed.
Any news on this max-lenght?
Re: POST Request with fetch
Posted: Wed Oct 25, 2017 11:38 am
by thantoldo
Can you please raise the 65535 character limit (double it or remove it completely), so that the error case "max line length 65535 exceeded!" is resolved?
It happens both with GET and POST (I understand that could occur with GET, but it shouldn't with POST)
As routerOS is more and more involved in the big data domain, it is imperative that such limitations are removed.
Any news on this max-lenght?
Just a note here, the fact that a variable doesn’t have such length limitation, makes the fetch data limitation much more awkward. The data can be collected locally in routeros, but they can’t be transmitted! (Well, there can be multiple fetches, but this is a nasty hack, both client and server wise)
Please raise or remove that limitation completely.
Re: POST Request with fetch
Posted: Fri Oct 27, 2017 11:14 am
by Setneuf
Can you please raise the 65535 character limit (double it or remove it completely), so that the error case "max line length 65535 exceeded!" is resolved?
It happens both with GET and POST (I understand that could occur with GET, but it shouldn't with POST)
As routerOS is more and more involved in the big data domain, it is imperative that such limitations are removed.
Any news on this max-lenght?
Just a note here, the fact that a variable doesn’t have such length limitation, makes the fetch data limitation much more awkward. The data can be collected locally in routeros, but they can’t be transmitted! (Well, there can be multiple fetches, but this is a nasty hack, both client and server wise)
Please raise or remove that limitation completely.
They had the limitation for sure because the GET and forgot to remove it when they implemented the POST, I believe that in a future release this will be fixed
Re: POST Request with fetch
Posted: Thu Dec 07, 2017 8:03 pm
by svda
How to send header in the method post or get? Option "-H" in curl. For example
curl -H 'PddToken: 123456789ABCDEF0000000000000000000000000000000000000' 'https://pddimp.yandex.ru/api2/admin/dns/list?domain=domain.com'
Encouraging an idea of fetching with custom headers. pdd.yandex.ru (name server api) requires using fields in the header
Re: POST Request with fetch
Posted: Sat Jan 13, 2018 5:42 pm
by Xenhat
I would like to reinforce the need for this functionality (specifically cURL's
custom header parameter for the same reasons.
Cloudflare is a widely used service and their V1 API seems to have been non-functional for write operations (and deprecated for several months if not years).
The inability to use these headers means we can no longer update DNS records from RouterOS itself, a feature extremely handy for users who are still stuck with dynamic IPs.
Is it possible to PUT Content-Type: application/json ? I would want to perform the following but i couldn't.
curl -X PUT "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records/372e67954025e0ba6aaa6d586b9e0b59" \
-H "X-Auth-Email: user@example.com" \
-H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"example.com","content":"127.0.0.1","ttl":120,"proxied":false}'
Re: POST Request with fetch
Posted: Mon Jan 29, 2018 6:46 am
by sheahant
I absolutely agree with above posts asking for header customization.
In the course of doing any diverse amount of API work, specifying the content-type header and then arbitrary headers inevitably come up as necessary features.
A bit further along, in some cases, comes the need to be able to read http-code, response-data and sometimes response-headers from the server reply - but request headers are fundamental.
Re: POST Request with fetch
Posted: Tue Mar 06, 2018 8:40 pm
by Dem0n3D
We need HEADERS!
Re: POST Request with fetch
Posted: Thu Mar 08, 2018 2:30 pm
by svda
As I see, it is already in release candidate
Re: POST Request with fetch
Posted: Thu Mar 08, 2018 2:42 pm
by normis
Re: POST Request with fetch
Posted: Thu Mar 08, 2018 10:07 pm
by lukaszg
This is for content type only right? To use it with the cloudflare we still need to wait for the headers support?
Re: POST Request with fetch
Posted: Thu Mar 15, 2018 5:23 pm
by jvianelfamilia
Hello, some body can help me on how can i call this url "
http://192.168.90.6/wifi/index.php/wifi ... arClientes" with fetch and make a schedule with this script execute auto every 5 minutes?
thanks in advange!
Re: POST Request with fetch
Posted: Sat Apr 07, 2018 6:25 pm
by awonglk
Can I get an idea when will "header" support be added to fetch tool?
This is quite useful for accessing API data which requires headers for authorization. Example by Xenhat already demonstrates this with DNS updates through Cloudflare which requires passing header details relating to Authorization in order to use their API.
I am not sure if svda is correct, in that header support is already available in release candidate already. I don't see mentions of it in the Changelog for 6.42rc52.
Re: POST Request with fetch
Posted: Thu Apr 19, 2018 7:25 pm
by pafflootiy
:local chann dude-1
:local notification "Time: [Time]\nAddress: [Device.CustomField2]\nIP: [Device.FirstAddress]\nPing: [Service.Status]"
:local iconurl https://wiki.mikrotik.com/images/5/54/Dude-icon3.png
:local pload "payload={\"channel\": \"#$chann\", \"username\": \"DUDE-server\", \"text\": \"$notification\", \"icon_url\": \"$iconurl\"}"
/tool fetch http-method=post http-content-type="application/json" http-data=$pload url="https://hooks.slack.com/services/TXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZZZZ" keep-result=no;
My script to send slack notifications
Re: POST Request with fetch
Posted: Sun Apr 29, 2018 1:48 pm
by godlike
A lot of APIs need custom headers for authentication.
Please, add ability to specify them.
Thanks!
Re: POST Request with fetch
Posted: Wed May 02, 2018 7:06 am
by xincun
Can I get an idea when will "header" support be added to fetch tool?
This is quite useful for accessing API data which requires headers for authorization. Example by Xenhat already demonstrates this with DNS updates through Cloudflare which requires passing header details relating to Authorization in order to use their API.
I am not sure if svda is correct, in that header support is already available in release candidate already. I don't see mentions of it in the Changelog for 6.42rc52.
Does rc already support "-H"? How to convert curl to fetch? Any example?
curl -X PUT "
https://api.cloudflare.com/client/v4/zo ... 586b9e0b59" \
-H "X-Auth-Email:
user@example.com" \
-H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"example.com","content":"127.0.0.1","ttl":120,"proxied":false}'
/tool fetch http-method=put http-content-type="application/json" http-data="{"type":"A","name":"example.com","content":"127.0.0.1","ttl":120,"proxied":false}" url="
https://api.cloudflare.com/client/v4/zo ... 586b9e0b59"
How to convert “-H”?
Re: POST Request with fetch
Posted: Fri Jun 01, 2018 5:53 pm
by Vargas
HEADERS are definitely a fundamental requirement in FETCH. Please consider at least the basic and standard headers.
For instance to send an SMS with content YYY to MSISDN +39XXX on connected russian Beeline ZTE MF831 LTE USB sticks you need to define the Referer.
With wget:
wget --post-data="isTest=false&goformId=SEND_SMS¬Callback=true&Number=%2B393XXX&MessageBody=YYY&ID=-1&encode_type=GSM7_default" --referer="
http://192.168.0.1/index.html"
http://192.168.0.1/goform/goform_set_cmd_process
An SMS message is sent.
With Fetch:
/tool fetch mode=http url="
http://192.168.0.1/goform/goform_set_cmd_process" http-method=post http-data="isTest=false&goformId=SEND_SMS¬Callback=true&Number=%2B39XXX&MessageBody=YYY&ID=-1&encode_type=GSM7_default" output=none
No referer header, therefore the command fails and no SMS from RouterOS.
Best regards
Re: POST Request with fetch
Posted: Mon Jul 30, 2018 9:12 pm
by krizzo
I looked through all the changelogs for RC as well as the current releases. I couldn't find anything indicating that fetch is getting the option for customizing headers. Is this feature something that will be added in the future?
Re: POST Request with fetch
Posted: Wed Aug 29, 2018 11:55 pm
by lustyffh
just heads up to this thread! I need digest authentication on post/get. and seems like Mikrotik doesn't support even that thing.
Re: POST Request with fetch
Posted: Wed Dec 12, 2018 6:53 pm
by колбаскин
Is it possible to PUT Content-Type: application/json ? I would want to perform the following but i couldn't.
curl -X PUT "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records/372e67954025e0ba6aaa6d586b9e0b59" \
-H "X-Auth-Email: user@example.com" \
-H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"example.com","content":"127.0.0.1","ttl":120,"proxied":false}'
Yes! Need this!
How to add -H "X-Auth-Email ?
Cloudflare not work (((
Re: POST Request with fetch
Posted: Thu Dec 13, 2018 11:06 am
by normis
Next RouterOS v6.44 beta will have custom header option
Re: POST Request with fetch
Posted: Fri Dec 14, 2018 3:08 pm
by колбаскин
6.44beta40 - this?
Or when?
I wrote an intermediate php script to update. I would like to do it right from the router
cloudflare.php
<?php
$zones = isset($_GET['zones']) ? trim($_GET['zones']) : exit;
$dns_records = isset($_GET['dns_records']) ? trim($_GET['dns_records']) : exit;
$zones = $_GET['zones'];
$dns_records = $_GET['dns_records'];
$name = $_GET['name'];
$content = $_GET['content'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.cloudflare.com/client/v4/zones/" . $zones . "/dns_records/" . $dns_records);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"type\":\"A\",\"name\":\"" . $name . "\",\"content\":\"" . $content . "\",\"ttl\":120,\"proxied\":false}");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
$headers = array();
$headers[] = "X-Auth-Email: max@hd.zp.ua";
$headers[] = "X-Auth-Key: 1c2c585915534145fecded4526e8668177a33";
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
var_dump($result);
curl_close ($ch);
?>
Need send to
cloudflare.php 4 parameters
Re: POST Request with fetch
Posted: Fri Dec 14, 2018 3:23 pm
by normis
no, 40 is the current one. the next one will be possibly 50
Re: POST Request with fetch
Posted: Wed Dec 19, 2018 11:21 am
by колбаскин
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" \
Re: POST Request with fetch
Posted: Wed Dec 19, 2018 11:28 am
by normis
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.
Re: POST Request with fetch
Posted: Fri Jan 18, 2019 7:22 pm
by pista
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.
18/01/2019 and still no multiple fetch header fields
Re: POST Request with fetch
Posted: Fri Jan 18, 2019 8:55 pm
by колбаскин
I put the intermediate script on php higher on the forum. You can download it to any server
viewtopic.php?f=9&t=120860&e=1&view=unread#p703390
/tool fetch mode=https url="
https://hd.zp.ua/cloudflare.php\?zones=$CFzones&dns_records=$CFtdnsrecords&name=$hostname&content=$externalIP" keep-result=no
Re: POST Request with fetch
Posted: Tue Feb 26, 2019 5:05 am
by bekax5
In the meantime this feature has been added.
Has anyone tried to use it with the Cloudflare v4 API ?
I am having difficulties with post to update a DNS zone.
It gives me error 400 bad request.
[admin@MikroTik-RB3011] > /tool fetch http-method=get url="https://api.cloudflare.com/client/v4/zones/__ZONEID__/dns_records/__ID__" http-header-field=X-Auth-Email:__EMAIL__,X-Auth-Key:__AUTH_KEY__,http-content-type:application/json output=none
status: finished
downloaded: 0KiBC-z pause]
duration: 1s
[admin@MikroTik-RB3011] > /tool fetch http-method=post url="https://api.cloudflare.com/client/v4/zones/__ZONEID__/dns_records/__ID__" http-header-field=X-Auth-Email:__EMAIL__,X-Auth-Key:__AUTH_KEY__,http-content-type:application/json output=none http-data="{\"type\":\"A\",\"name\":\"__A_RECORD__\",\"content\":\"192.168.1.1\"}"
status: failed
failure: closing connection: <400 Bad Request> 104.19.198.151:443 (4)
Re: POST Request with fetch
Posted: Tue Feb 26, 2019 5:08 pm
by pista
In the meantime this feature has been added.
Has anyone tried to use it with the Cloudflare v4 API ?
I am having difficulties with post to update a DNS zone.
It gives me error 400 bad request.
[admin@MikroTik-RB3011] > /tool fetch http-method=get url="https://api.cloudflare.com/client/v4/zones/__ZONEID__/dns_records/__ID__" http-header-field=X-Auth-Email:__EMAIL__,X-Auth-Key:__AUTH_KEY__,http-content-type:application/json output=none
status: finished
downloaded: 0KiBC-z pause]
duration: 1s
[admin@MikroTik-RB3011] > /tool fetch http-method=post url="https://api.cloudflare.com/client/v4/zones/__ZONEID__/dns_records/__ID__" http-header-field=X-Auth-Email:__EMAIL__,X-Auth-Key:__AUTH_KEY__,http-content-type:application/json output=none http-data="{\"type\":\"A\",\"name\":\"__A_RECORD__\",\"content\":\"192.168.1.1\"}"
status: failed
failure: closing connection: <400 Bad Request> 104.19.198.151:443 (4)
To update DNS zone, you must use PUT method. Replace
http-method=post with
http-method=put and add
mode=https
Re: POST Request with fetch
Posted: Tue Feb 26, 2019 7:11 pm
by bekax5
In the meantime this feature has been added.
Has anyone tried to use it with the Cloudflare v4 API ?
I am having difficulties with post to update a DNS zone.
It gives me error 400 bad request.
[admin@MikroTik-RB3011] > /tool fetch http-method=get url="https://api.cloudflare.com/client/v4/zones/__ZONEID__/dns_records/__ID__" http-header-field=X-Auth-Email:__EMAIL__,X-Auth-Key:__AUTH_KEY__,http-content-type:application/json output=none
status: finished
downloaded: 0KiBC-z pause]
duration: 1s
[admin@MikroTik-RB3011] > /tool fetch http-method=post url="https://api.cloudflare.com/client/v4/zones/__ZONEID__/dns_records/__ID__" http-header-field=X-Auth-Email:__EMAIL__,X-Auth-Key:__AUTH_KEY__,http-content-type:application/json output=none http-data="{\"type\":\"A\",\"name\":\"__A_RECORD__\",\"content\":\"192.168.1.1\"}"
status: failed
failure: closing connection: <400 Bad Request> 104.19.198.151:443 (4)
To update DNS zone, you must use PUT method. Replace
http-method=post with
http-method=put and add
mode=https
Thanks for the reply!!
Lol, I actually just missed that hahah.
Even though the error still persists, am I still missing something ?
[admin@MikroTik-RB3011] > /tool fetch http-method=put mode=https url="https://api.cloudflare.com/client/v4/zones/__ZONEID__/dns_records/__ID__" http-header-field=X-Auth-Email:__EMAIL__,X-Auth-Key:__AUTHKEY__,http-content-type:application/json output=none http-data="{\"type\":\"A\",\"name\":\"__ARECORD__\",\"content\":\"192.168.1.1\"}"
status: failed
failure: closing connection: <400 Bad Request> 104.19.195.151:443 (4)
Re: POST Request with fetch
Posted: Tue Feb 26, 2019 8:29 pm
by pista
In the meantime this feature has been added.
Has anyone tried to use it with the Cloudflare v4 API ?
I am having difficulties with post to update a DNS zone.
It gives me error 400 bad request.
[admin@MikroTik-RB3011] > /tool fetch http-method=get url="https://api.cloudflare.com/client/v4/zones/__ZONEID__/dns_records/__ID__" http-header-field=X-Auth-Email:__EMAIL__,X-Auth-Key:__AUTH_KEY__,http-content-type:application/json output=none
status: finished
downloaded: 0KiBC-z pause]
duration: 1s
[admin@MikroTik-RB3011] > /tool fetch http-method=post url="https://api.cloudflare.com/client/v4/zones/__ZONEID__/dns_records/__ID__" http-header-field=X-Auth-Email:__EMAIL__,X-Auth-Key:__AUTH_KEY__,http-content-type:application/json output=none http-data="{\"type\":\"A\",\"name\":\"__A_RECORD__\",\"content\":\"192.168.1.1\"}"
status: failed
failure: closing connection: <400 Bad Request> 104.19.198.151:443 (4)
To update DNS zone, you must use PUT method. Replace
http-method=post with
http-method=put and add
mode=https
Thanks for the reply!!
Lol, I actually just missed that hahah.
Even though the error still persists, am I still missing something ?
[admin@MikroTik-RB3011] > /tool fetch http-method=put mode=https url="https://api.cloudflare.com/client/v4/zones/__ZONEID__/dns_records/__ID__" http-header-field=X-Auth-Email:__EMAIL__,X-Auth-Key:__AUTHKEY__,http-content-type:application/json output=none http-data="{\"type\":\"A\",\"name\":\"__ARECORD__\",\"content\":\"192.168.1.1\"}"
status: failed
failure: closing connection: <400 Bad Request> 104.19.195.151:443 (4)
OK
In header field replace
http-content-type:application/json with
content-type:application/json
Re: POST Request with fetch
Posted: Tue Feb 26, 2019 8:32 pm
by bekax5
OK
In header field replace
http-content-type:application/json with
content-type:application/json
Hahahah, nice catch!
I've been trying this on yesterday's late night and I probably wasn't even looking anymore.
Thanks a lot, it worked perfectly.
Re: POST Request with fetch
Posted: Thu Feb 28, 2019 9:56 am
by Cliff
Has anyone sent messages to Rocketchat?
I have the curl:
curl -X POST -H 'Content-Type: application/json' --data '{"text":"Example"}' http://myip:3000/hooks/SHFuHFpDFHFOEFHOI5984w798q
And it work perfectly in linux.
Trying to convert in into fetch:
/tool fetch keep-result=no mode=http url="http://myip:3000/hooks/SHFuHFpDFHFOEFHOI5984w798q" http-method=post http-content-type="application/json" http-data="\"text\":\"Example message\""
But receive error:
failure: closing connection: <400 Bad Request> myip:3000 (4)
Re: POST Request with fetch
Posted: Thu Feb 28, 2019 11:10 am
by normis
Your http-data doesn't look like JSON at all, you only have quotes in there.
Re: POST Request with fetch
Posted: Thu Feb 28, 2019 11:28 am
by Cliff
My bad, forgot { }. Thanks.
Re: POST Request with fetch
Posted: Thu Feb 28, 2019 3:10 pm
by WeWiNet
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
Re: POST Request with fetch
Posted: Thu Feb 28, 2019 3:19 pm
by normis
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
Re: POST Request with fetch
Posted: Thu Feb 28, 2019 4:45 pm
by WeWiNet
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.
Re: POST Request with fetch
Posted: Thu Feb 28, 2019 4:58 pm
by normis
No, it should be enough with that link
Re: POST Request with fetch
Posted: Fri Mar 01, 2019 10:07 am
by WeWiNet
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...
Re: POST Request with fetch
Posted: Fri Mar 01, 2019 10:55 am
by normis
Thanks for sharing the full guide, it will be useful to others who want to use IFTTT
Re: POST Request with fetch
Posted: Fri Mar 01, 2019 10:56 am
by колбаскин
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?
Re: POST Request with fetch
Posted: Fri Mar 01, 2019 11:03 am
by normis
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
Re: POST Request with fetch
Posted: Fri Mar 01, 2019 4:18 pm
by ivanfm
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.
Re: POST Request with fetch
Posted: Tue Mar 05, 2019 4:08 pm
by WeWiNet
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
Re: POST Request with fetch
Posted: Tue Mar 05, 2019 5:06 pm
by mrz
http-header-field="Content-Type: application/json"
Re: POST Request with fetch
Posted: Tue Mar 05, 2019 6:46 pm
by WeWiNet
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
Re: POST Request with fetch
Posted: Fri Mar 15, 2019 9:47 am
by taxist
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"
Re: POST Request with fetch
Posted: Thu Apr 04, 2019 12:39 pm
by WeWiNet
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?
Re: POST Request with fetch
Posted: Fri May 10, 2019 1:51 pm
by tempoff
Hello everyone!
Can you also add a patch http method to fetch tool please? It can be very useful.
mikrotik does not recognize intel network card
Posted: Fri May 17, 2019 4:02 pm
by bruna
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 !
Re: POST Request with fetch
Posted: Tue Aug 20, 2019 10:48 am
by rilliam
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"
Wow wish this was on the man page for fetch. I just wasted two nights trying to figure this out.
If you don't use lower case, fetch will send two header-fields for content-type, one with the correct MIME type and the other with default webform MIME type.
Re: POST Request with fetch
Posted: Sat Aug 24, 2019 12:11 pm
by iqbaldalban
hello everyone, in the past few days I have experienced a problem with the fetch script that suddenly doesn't want to run anymore. maybe someone here knows the cause.
This is an example of a fetch script that I use to auto login to the wifi captive portal
{
log error ("Internet Mati --- Memulai Koneksi Ulang ......")
/ip dns cache flush
/ip dhcp-client release [find interface=wlan2]
log warning ("DHCP Client Baru")
delay 10
:local ip [/ip address get [/ip address find interface="wlan2"] address];
:local macadd [/interface wireless get [ find default-name=wlan2 ] mac-address];
:local ip [put [:pick $ip 0 [:find $ip "/"]]]
/tool fetch http-method=post http-data="username_=DalBan&username=DalBan.lPgC%40freeMS&password=DalBan" url=("https://welcome2.wifi.id/wms/auth/authnew/autologin/quarantine.php?ipc=$ip&gw_id=WAG-D4-GBL&mac=$macadd&wlan=TGSLW00005/TLK-WI124968-0001:UN%20CHECK") keep-result=no
log warning ("Internet Sudah Menyala")
}
and this is the current data fetch that I took through the chrome network
fetch("https://welcome2.wifi.id/wms/auth/authnew/autologin/quarantine.php?ipc=10.148.103.193&gw_id=WAG-D4-GBL&mac=b4:cb:57:6f:7a:91&redirect=http://8.8.8.8/&wlan=TGSLW00005/TLK-WI124968-0001:RUMAH%20IQBAL&landURL=", {"credentials":"include","headers":{"accept":"application/json, text/javascript, */*; q=0.01","accept-language":"en","content-type":"application/x-www-form-urlencoded; charset=UTF-8","sec-fetch-mode":"cors","sec-fetch-site":"same-origin","x-requested-with":"XMLHttpRequest"},"referrer":"https://welcome2.wifi.id/wms/?gw_id=WAG-D4-GBL&client_mac=b4:cb:57:6f:7a:91&wlan=TGSLW00005/TLK-WI124968-0001:RUMAH%20IQBAL&sessionid=0800FFFF7802E286-5D60F78B&redirect=http://8.8.8.8/","referrerPolicy":"no-referrer-when-downgrade","body":"username_=DalBan&username=DalBan.xJjh%40freeMS&password=DalBan","method":"POST","mode":"cors"});
Re: POST Request with fetch
Posted: Sat Dec 07, 2019 9:31 am
by brewer7
Guys, can you help me out here.
i'm trying to make a script to send text (SMS) via hilink Huawei E8372. i've found a few solutions on CURL like
this or
this. I've decided to rework this script for Mikrotik (i have RB951 ROS v6.45.3).
I've stucked truing to get authorized on the Web interface.
here wthat i have for now:
/tool fetch url="http://192.168.8.1/api/webserver/SesTokInfo" dst-path="ses_tok.txt"
global content [/file get [/file find name=ses_tok.txt] contents]
:local COOKIE [:pick $content 71 199]
:local TOKEN [:pick $content 220 252]
:local LOGIN "<request><Username>admin</Username><Password>admin</Password><password_type>3</password_type></request>"
log info "COOKIE: $COOKIE"
log info "TOKEN: $TOKEN"
/tool fetch mode=http http-method=post url="http://192.168.8.1/api/user/login" http-data=($LOGIN) http-header-field=(Cookie:$COOKIE,__RequestVerificationToken:$TOKEN,content-type:text/xml,Connection:keep-alive) dst-path="login_resp_hdr.txt" keep-result=no
but no file after 2nd fetch command downloaded.
In the meantime in log:
18:17:58 info fetch: file "ses_tok.txt" downloaded
18:17:58 script,info COOKIE: hoVS1kv8/waT0S4OyMrwZQS5OFOymv1Ruy6XovYaLK7xffO2v2mjP
PctukTNEuc7NhK1jdqE0X8c/DjIxyWMrqKmp6K3x74n1ja8xrVY/pMJCg3YJzXf1jwMIybRaxG7
18:17:58 script,info TOKEN: 1L719lqR/w/T/XnOu+pu3JBj75e3EIAH
i beulive the issue is in how i describe http-header-field. What am i doing wrong?
Re: POST Request with fetch
Posted: Wed Feb 19, 2020 11:51 pm
by oneblade
Hello
How to replace the linux script shown below to make it work in mikrotik? The script updates the dmz host on the ISP's router.
#!/bin/bash
curl -u admin:password \
-c cookie_router \
-X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "SelectLanguage=en_US&LogoutApplyAction=&DMZHostIP0=192.168.1.200&RouterIPAddress=192.168.1.1" \
http://192.168.1.1/goform/AdvancedDMZHost
I will be grateful for help because I am just starting with mikrotik
Re: POST Request with fetch
Posted: Wed Mar 11, 2020 8:03 pm
by kai
OK
In header field replace
http-content-type:application/json with
content-type:application/json
Hahahah, nice catch!
I've been trying this on yesterday's late night and I probably wasn't even looking anymore.
Thanks a lot, it worked perfectly.
Sorry to bring up a post from the dead.. but I can't find anything more recent.
I'm having some trouble with Cloudflare, getting a 400 Bad request, yet when I do it manually through cURL, it will work successfully, just not through RouterOS.
These are the commands:
/tool fetch mode=https http-method=put url="https://api.cloudflare.com/client/v4/zones/__ZONEID__/dns_records" http-header-field="content-type:application/json,X-Auth-Email:__EMAIL__,X-Auth-Key:__APIKEY__" http-data="{\"type\":\"A\",\"name\":\"__DOMAIN__\",\"content\":\"__IPADDRESS__\",\"ttl\":120,\"proxied\":false}" output=none
//working
curl -X POST "https://api.cloudflare.com/client/v4/zones/__ZONEID__/dns_records" -H "X-Auth-Email: __EMAIL__" -H "X-Auth-Key: __APIKEY__" -H "Content-Type: application/json" --data '{"type":"A","name":"__DOMAIN__","content":"__IPADDRESS__","ttl":120,"priority":10,"proxied":false}'
Anyone else have the same problem?
Re: POST Request with fetch
Posted: Wed Mar 25, 2020 4:40 pm
by dejoebad
with fetch, how can I do curl command like this:
curl -X POST -d @sw_debug_mode.xml
http://192.168.8.1/CGI
please assist me, i'm very new with this✌☺
Re: POST Request with fetch
Posted: Mon Mar 30, 2020 1:02 pm
by tempoff
Hello everyone!
Can you also add a patch http method to fetch tool please? It can be very useful.
Guys?
Re: POST Request with fetch
Posted: Tue Jun 02, 2020 3:24 am
by alkaafi
can help me?
<form id="loginForm" action="https://welcome2.wifi.id/wms/auth/authnew/autologin/quarantine.php?ipc=10.212.63.176&gw_id=WAG-D5-KBL&mac=14:4d:67:98:69:9c&redirect=&wlan=BWRGJ00021-N%2FTLK-CI-47595%3Aelkafii" method="post">
<input type="text" name="username" id="username_hidden" value="2078orla.Ai03@freeMS" />
<input type="text" name="password" id="password" value="2078orla" />
<input type="submit" value="oke" />
</form>
for auto login
{:local wmsip "10.212.63.176";
:local wmsmac "14:4d:67:98:69:9c";
:local wmspass "2078orla";
:local wmsssid "BWRGJ00021-N%2FTLK-CI-47595%3Aelkafii";
:local urllogin "https://welcome2.wifi.id/wms/auth/authnew/autologin/quarantine.php\?ipc=$wmsip&gw_id=WAG-D5-KBL&mac=$wmsmac&redirect=&wlan=$wmsssid";
:local ppostform "ipc=$wmsip&gw_id=WAG-D5-KBL&mac=$wmsmac&redirect=&wlan=$wmsssid&payload={\"username\":\"$wmspass.Ai03@freeMS\",\"password\":\"$wmspass\"}";
/log err $ppostform
/ip dns cache flush
:local wmsrespon ([/tool fetch mode=https http-method=post http-data=$ppostform url="$urllogin" http-header-field="content-type:application/json,User-Agent: chrome browser mumet" as-value output=user]->"data");
/log war $wmsrespon;}
please
Re: POST Request with fetch
Posted: Sun Aug 16, 2020 4:58 am
by iyadseizer
hello all
that is easy way to fetch your data
in
[important]
[flash=]example[/flash]
http-header-field="Authorization:key=Izalg..gf,Content-Type:application/json"
and in body you will write a json template as this
http-data="{\"to\":\"deviceToken\",\"notification\":{\"title\":\"hello\",\"body\":\"world\"}}"
that is a full way i used at firebase notification from my server to my android app
regurds
Re: POST Request with fetch
Posted: Wed Dec 22, 2021 6:55 am
by knedlyk
Hi! Please, help to convert this string into the fetch format:
curl -d '{"token": "<roomid>", "message": "hi there @<username>"}' -H "Content-Type: application/json" -H "Accept: application/json" -H "OCS-APIRequest: true" -v -u "<username>:<password>" https://mydomain.tld/ocs/v1.php/apps/spreed/api/v1/chat/<roomid>
Let me add that
https://kigiri.github.io/fetch/ gives me the following solution:
fetch("https://domaintld/ocs/v1.php/apps/spreed/api/v1/chat/<roomid>", {
body: "{"token": "<roomid>", "message": "hi there @<username>"}",
headers: {
Accept: "application/json",
Authorization: "Basic <hash here=>",
"Content-Type": "application/json",
"Ocs-Apirequest": "true"
},
method: "POST"
})
I tried to convert it to
/tool fetch http-method=post http-header-field="{Accept:\"appli
cation/json\",Authorization:\"Basic <hash here=>\",\"Content-Type\":\"appl
ication/json\",\"OCS-APIRequest\":\"true\"}" http-data="{\"token\":\"<roomid>\",\"message\":\"hi t
here @<username>\"}" url="domain.tld/ocs/v1.php/apps/spreed/api/v1/chat/<roomid>"
user="<username>" password="<password>"
However, got the response:
status: failed
failure: closing connection: <412 Precondition failed> 144.**.**.***:443 (5)
Playing with adding or not adding user and password didn't help.
Please, help with that. Thanks!
Re: POST Request with fetch
Posted: Wed Dec 22, 2021 4:04 pm
by Amm0
Hi! Please, help to convert this string into the fetch format:
curl -d '{"token": "<roomid>", "message": "hi there @<username>"}' -H "Content-Type: application/json" -H "Accept: application/json" -H "OCS-APIRequest: true" -v -u "<username>:<password>" https://mydomain.tld/ocs/v1.php/apps/spreed/api/v1/chat/<roomid>
/tool/fetch follows RouterOS usual scheme for commands and types, so a direct conversation isn't possible... While shares same name as the W3C fetch(), it actually pretty different in operation. The curl example is closer to what's needed.
For references... Mikrotik's old docs describe the parameters better:
https://wiki.mikrotik.com/wiki/Manual:Tools/Fetch
The new docs have better examples:
https://help.mikrotik.com/docs/display/ ... ch-Summary
The HTTP example for IoT with KNOT is more
fuller example of using /tool/fetch.
So focusing on the CURL -> /tool/fetch pthings
I tried to convert it to
/tool fetch http-method=post http-header-field="{Accept:\"appli
cation/json\",Authorization:\"Basic <hash here=>\",\"Content-Type\":\"appl
ication/json\",\"OCS-APIRequest\":\"true\"}" http-data="{\"token\":\"<roomid>\",\"message\":\"hi t
here @<username>\"}" url="domain.tld/ocs/v1.php/apps/spreed/api/v1/chat/<roomid>"
user="<username>" password="<password>"
However, got the response:
status: failed
failure: closing connection: <412 Precondition failed> 144.**.**.***:443 (5)
Mikrotik doesn't have native JSON support, so it's generally not used in most parameters to /tool/fetch. While it's need for the "http-data" – since JSON is what the other side wants, ROS allows you to send a encode string with it as you found out. e.g. the "{\"field\":\"value\"}" stuff is JSON and needed in http-data ONLY. Mikrotik requires you escape the JSON (specifically JSON's required quotes around attribute names) which look like you've done.
But "http-header-field=<...>"
does not take JSON (but W3C fetch() does, why the confusion I'm sure) – so your escaping/formating of JSON the into this field is the issue. In HTTP, the actual key:value headers pars don't use JSON, they use a : colon. The
old docs document the format, so use HTTP's colon format here. With Mirotik telling you to separate out multiple headers by a ",". So in theory, the fix for your case is to use:
http-header-field="Content-Type:application/json,OCS-APIRequest:true,Accept:application/json"
You may need the "Authentication" line, but think that will get set automatically by RouterOS when you use user= password= (can't recall). And yeah perhaps escaping. But that the header line is issue I suspect.
Re: POST Request with fetch
Posted: Tue Dec 28, 2021 3:34 am
by knedlyk
You may need the "Authentication" line, but think that will get set automatically by RouterOS when you use user= password= (can't recall). And yeah perhaps escaping. But that the header line is issue I suspect.
Many-many-many thanks for your so kind guidance. It works now!
What I would like to improve is to use the anonymous posts in public conversations, however it brings additional pain: need to use 2 curls and analyse cookies. I have had a conversation with the Talk's devs, and they left not so easy to take ideas
https://github.com/nextcloud/spreed/issues/6736.
In case of MT I wouldn't like to store the cookies on the device side, but rather try to place them in vars. In any case, do you think it will be possible to obtain them at all?
Thanks again!
Re: POST Request with fetch
Posted: Tue Dec 28, 2021 3:56 am
by Amm0
You may need the "Authentication" line, but think that will get set automatically by RouterOS when you use user= password= (can't recall). And yeah perhaps escaping. But that the header line is issue I suspect.
What I would like to improve is to use the anonymous posts in public conversations, however it brings additional pain: need to use 2 curls and analyse cookies. I have had a conversation with the Talk's devs, and they left not so easy to take ideas
https://github.com/nextcloud/spreed/issues/6736.
You might want to start a
new topic in the forum, explaining what you're planning/doing with /tool/fetch & nextcloud. This thread is now 3+ years old, so new subtopics get really confusing. Plus, you may not be only person using a Mikrotik to Nextcloud. They seems to have a few possible APIs...maybe someone has a script already.
Re: POST Request with fetch
Posted: Sat Jan 01, 2022 2:53 pm
by knedlyk
What I would like to improve is to use the anonymous posts in public conversations, however it brings additional pain: need to use 2 curls and analyse cookies. I have had a conversation with the Talk's devs, and they left not so easy to take ideas
https://github.com/nextcloud/spreed/issues/6736.
You might want to start a
new topic in the forum, explaining what you're planning/doing with /tool/fetch & nextcloud. This thread is now 3+ years old, so new subtopics get really confusing. Plus, you may not be only person using a Mikrotik to Nextcloud. They seems to have a few possible APIs...maybe someone has a script already.
Thanks! I will probably follow your advice. Have a good start of the New year!
Re: POST Request with fetch
Posted: Sun Aug 13, 2023 7:37 am
by austinNz
Late reply but for anyone searching for this now like me I found out it is much easier to send out the http-data as an array
:local arr {"mac"="aa:bb:cc:dd:ee:ff";"ip"="192.168.100.80"}; /tool fetch url=("https://some-server.com/index.php") http-method=https http-data=$arr mode=post keep-result=yes;
In the php file I can read the post array as $_POST["mac"] and $_POST["ip"]
Re: POST Request with fetch
Posted: Thu Nov 16, 2023 12:52 pm
by stevedavis
Does anyone know if it is possible to do something similar to POST but using a plain Telnet like data stream rather than HTTP application specific?
I just need to send text to a port at an address , a bit like you can manually send commands to an email server or http server from a Telnet client.
Thanks