Community discussions

MikroTik App
 
troy
Member
Member
Topic Author
Posts: 320
Joined: Thu Jun 30, 2005 6:47 pm

fetch vs curl

Fri Jan 12, 2024 4:34 pm

Trying to write a script, specifically to hit a webhook on MS Teams. Fetch from both ROS6 and ROS7 result in a "400 Bad Request" from the web server, while curl works just fine.
[admin@mikrotik] > tool fetch http-method=post mode=https http-header-field="Content: application/json" url=$myURL \
 http-data="{\"Summary\":\"Test Summary\",\"title\":\"Test Title\",\"text\":\"Test Message\"}"
[troy@myserver ~]$ curl -H 'Content-Type: application/json' -d "{\"Summary\":\"Test Summary\",\"title\":\"Test Title\",\"text\":\"Test Message\"}" $myURL
Not even sure how to begin figuring this out.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3509
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: fetch vs curl  [SOLVED]

Fri Jan 12, 2024 5:08 pm

Your header is wrong:

http-header-field="Content-Type: application/json"

You may want to add output=user, so you can see the results on the screen. Otherwise output is to a file. If it all works, you can add "as-value" to store result to a variable if desired.
 
troy
Member
Member
Topic Author
Posts: 320
Joined: Thu Jun 30, 2005 6:47 pm

Re: fetch vs curl

Fri Jan 12, 2024 9:14 pm

I'm BLIND!

Thank you.

Who is online

Users browsing this forum: No registered users and 9 guests