I am new to Foswiki and am wondering if it is possible to access the contents of a META form directly using an API call. A simple example of code to do this would be helpful.
Asked
Active
Viewed 93 times
1 Answers
2
Do you mean using a REST API or from within Perl?
Here is how to create custom REST API to access a formfield of some source:
(1) Create a topic, say FoswikiAPI, with content:
<verbatim class="tml">
%STARTSECTION{"getformfield"}%%FORMFIELD{
"%URLPARAM{"formfield"}%"
topic="%URLPARAM{"source"}%"
}%%ENDSECTION{"getformfield"}%
</verbatim>
(2) call it like this:
http://.../FoswikiAPI?skin=text§ion=getformfield&formfield=FooBar&source=SomeWeb.SomeTopic
To read a topic and access its meta data from within perl please have a look at

nuddlegg
- 141
- 1
- 4
-
Thanks. Yes I mean REST. I wondered if you could expand on how to call the API url and read the META form. For example I have seen 'Foswiki::Func: readTopic( $web, $topic, $rev )' but I'm not sure how I can implement that. I would like to use Python3 code. – 2one Feb 28 '19 at 15:08
-
1Maybe I wasn't clear. Step (2) actually _is_ the REST call to some wiki page on your system. Say your system is on wiki.intranet.local, then the REST call would be http://wiki.intranet.local/bin/view/System/FoswikiAPI?skin=text§ion=getformfield&formfield=FooBar&source=SomeWeb.SomeTopic to extract the specified formfield from the source page. Note, you will have to create an page FoswikiAPI with the content given in step (1). – nuddlegg Mar 01 '19 at 16:08
-
1Oh and on the commandline this would be `./view topic=System.FoswikiAPI section=getformfield source=SomeWeb.SomeTopic formfield=FooBar skin=text` – nuddlegg Mar 01 '19 at 16:24
-
@nuddlegg This thread is close to what I intend to do with foswiki. I want to create a topic on foswiki instance running on web server on local machine with data coming from external system. The topic data will be sent via POST request from external system to this local machine's (server URL) port XXXX. When the data arrives at the port XXXX some how a new topic/update topic if exist event should be triggered on foswiki. How can I achieve this? – P_Z Feb 16 '22 at 17:17