Adding asset using API

Hi there,

I’m exploring the API to add assets to Anthias.

For now, I’ve been able to GET and DELETE and PATCH assets (e.g. flipping the ‘is_enabled’ boolean) through Python’s requests library and/or Postman, but am unable to truly add an asset.

When I try with following POST call:

{“name”: “test123”, “mimetype”: “webpage”, “uri”: “http://www.google.com”, “is_enabled”: “0”}

I get:

{“error”: “Not enough information provided. Please specify ‘name’, ‘uri’, ‘mimetype’, ‘is_enabled’, ‘start_date’ and ‘end_date’.”}

OK, so let’s provide start/end date:

{“name”: “test123”, “mimetype”: “webpage”, “uri”: “http://www.google.com”, “is_enabled”: “0”, “start_date”: “2017-02-02T00:33:00.000”, “end_date”: “2025-02-02T00:33:00.000”}

However that yields:

{“error”: “invalid literal for int() with base 10: ‘’”}

I assume this has to do with the datetime format I’m posting. What kind of format is expected for start/end date?
The format above is the one I got from the swagger example.
I tried with various other formats such as “2023-04-10T18:50:00+00:00”, “04/10/2023 22:24:00” (shown on the web page), epoch “1681372113”, and few more.

Any pointer on this? Thanks!

I dont want to type too much so take a look at how i was doing it here on this side thing i did for my own personal easy way to manage multiple anthias:

Sorry I see that you want the actual POST commands…

here is some code i found from my old days of messing with API commands…

### to add asset and enable it (edit IP address before submitting if necessary)
curl -s -X POST "http://192.168.1.8/api/v1.2/assets" \
	-H "accept: application/json" \
	-H "content-type: application/json" \
	-d "{  \"mimetype\": \"webpage\", \
	\"is_enabled\": 1, \
	\"name\": \"bing homepage\", \
	\"end_date\": \"9999-01-01T00:00:00.000Z\", \
	\"duration\": \"30\", \
	\"uri\": \"https://www.bing.com\", \
	\"skip_asset_check\": 1, \
	\"start_date\": \"2020-11-17T07:37:28.486Z\"}"

#

curl -X POST "http://192.168.1.10/api/v1.2/assets" -H  "accept: application/json" -H  "content-type: application/json" -d "{  \"mimetype\": \"webpage\",  \"is_enabled\": 1,  \"name\": \"weather screenly io\",  \"end_date\": \"2021-11-17T07:37:28.486Z\",  \"duration\": \"30\",  \"uri\": \"https://weather.srly.io?lang=en&24h=0&wind_speed=0\",  \"skip_asset_check\": 1,  \"start_date\": \"2020-11-17T07:37:28.486Z\"}"