API to create events and more
Hi,
I have some sources (ics files, lists, xml files and others) with data I want to add. In my case there are data of events. Copy them one by one in the web interface is a pain the the a...
So I was thinking: Hey, there is an api to put all this in for sure!
But when I see it correct there is (for events) just a read-only interface. Is there a plan to implement also an interface to post data / create entries? Or maybe a kind of a generic "Fill out form xy" function?
-
-
·
LeonidS
- ·
Hello @Callya !
Yes, UNA has the api for that. For example to add content to Posts module it's possible to call
serviceEntityAddservice function:curl -H 'Authorization: Bearer tmw.msZjv4MEpwBt6Gku6Wjzvu5i9DX7LkMZdC+8AbWar&px' "http://example.com/una/api.php?r=bx_posts/entity_add¶ms=%5B3%2C%7B%22title%22%3A%22Test%20title2%22%2C%22cat%22%3A3%2C%22text%22%3A%22Post%20text%22%2C%22allow_view_to%22%3A3%7D%5D"So you may write the script, which, will parse your files with data and refer to this api page.
-
·
LeonidS
-
- · Callya
- ·
Thank you for the answer. But as usual the documentation really needs more attention.
Here for example:
- On this page (https://unacms.com/wiki/Dev-API) the authentication methods are described with an example how to add an entry using the posts module.
- A List with safe and unsafe services is not there.
I'm trying now for hours to create one event using the api and got already a few hundred times "HTTP 404" because I just don't find the correct value for "r=".
I've found a "insert"function in BxEventsFormEntry.php, but it can not be called from the api.
-
- · Zyrgon Portugal
- ·
Hello @Callya , in this time you have found some solution to this? I'm trying to create a timeline_common_post via API but the method `serviceEntityAdd` don't work in this case nether.
-
-
·
Alex T⚜️
- ·
@Callya @Zyrgon Portugal All the API endpoints to add/edit/delete content are described here - https://ci.una.io/docs/service.html#bx_system_general-content-objects
Particularly for adding the content - https://ci.una.io/docs/service.html#bx_system_general_cnt-add
-
·
Alex T⚜️
-
- · Callya
- ·
With this "System Content Add" it is somehow working to create an event. It is getting an event generated with author 0, what leads to fail to create the corresponding entry to sys_profiles. In Apache error log I can find this: "PHP Fatal error: Uncaught Error: Call to a member function getAccountId() on bool"
Imho this means I have to declare somehow who is the author. Correct?
-
- · Callya
- ·
It is working now. To finish this case here:
The API docs are false. In the docs is written that you must login with "curl -sv --cookie "memberSession=SESSIONIDHERE" -H "Authorization: Bearer..." this returns some data and here is the error.
In the docs is written that you can create an entry with "curl -s --cookie 'memberSession=SESSIONID' -H 'Authorization: Bearer..." but you have to use "curl -s --cookie 'memberID=1' --cookie 'memberSession=abcdefghijklmnop' --cookie 'memberPassword=12345abcd -H 'Authorization: Bearer..."
So in the cookie memberID and memberPassword must be set also out of the response from the login.