0

Using HTTPie https://httpie.org/doc#usagehow do I create a custom URL that I can use to insert my api endpoint?

if given a base url for example that I want to append a date too to reach the endpoint

/myURL/data

/myURL/data/yyy/mm/dd

how can I add the date programmatically in the url to reach the endpoint repeatedly over days. For today it would look like

/myURL/data/2017/07/13

Ultimately I will be calling this daily so want to be able to set this up

sayth
  • 6,696
  • 12
  • 58
  • 100

1 Answers1

1

What platform are you using? It looks like your options are OSX or Linux so this should work on either.

You can use the date program to format todays date:

date +%Y/%m/%d

Which (today) outputs 2017/07/13.

You could roll a small script to construct your URL parameter and call httpie, something like this:

#!/bin/bash

today=$(date +%Y/%m/%d)

http /myURL/data/$today

Which would execute http /myURL/data/2017/07/13

Then you could set up a cron (or launchd on OSX) to call the script each day.

Matt
  • 3,677
  • 1
  • 14
  • 24