title: WidgetMessage: tm-http-request Example - Zotero
tags: $:/tags/Macro
\define select-zotero-group()
Specify the Zotero group ID to import
<$edit-text tiddler="$:/config/zotero-group" tag="input"/> or
<$select tiddler="$:/config/zotero-group">
$select>
\end
\define zotero-save-item(item)
<$action-createtiddler
$basetitle={{{ =[[_zotero_import ]] =[- jsonget[key]] =[[ ]] =[
- jsonget[title]] +[join[]] }}}
text={{{ [
- jsonget[title]] }}}
tags="$:/tags/ZoteroImport"
>
<$action-setmultiplefields $tiddler=<> $fields="[
- jsonindexes[]addprefix[zotero-]]" $values="[
- jsonindexes[]] :map[
- jsongetelse[.XXXXX.]]"/>
<$list filter="[
- jsonindexes[creators]]" variable="creatorIndex">
<$action-setmultiplefields $tiddler=<> $fields="[
- jsonget[creators],,[creatorType]addprefix[zotero-]]" $values="[
- jsonget[creators],,[lastName]] [
- jsonget[creators],,[firstName]] +[join[, ]] :else[
- jsonget[creators],,[name]] "/>
$list>
$action-createtiddler>
\end zotero-save-item
\define zotero-save-items(data)
<$list filter="[jsonindexes[]] :map[jsonextract,[data]]" variable="item">
<$macrocall $name="zotero-save-item" item=<
- >/>
$list>
\end zotero-save-items
\define zotero-get-items(start:"0",limit:"25")
\define completion()
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
<$action-log msg="In completion"/>
<$action-log/>
<$list filter="[compare:number:gteq[200]compare:number:lteq[299]]" variable="ignore">
<$macrocall $name="zotero-save-items" data=<>/>
<$list filter="[jsonget[total-results]subtractsubtractcompare:number:gt[0]]" variable="ignore">
<$macrocall $name="zotero-get-items" start={{{ [add] }}} limit=<>/>
$list>
$list>
\end completion
\define progress()
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
<$action-log message="In progress-actions"/>
\end progress
\define request-url()
\rules only transcludeinline transcludeblock filteredtranscludeinline filteredtranscludeblock
https://api.zotero.org/groups/{{$:/config/zotero-group}}/items/
\end request-url
<$wikify name="url" text=<>>
<$action-sendmessage
$message="tm-http-request"
url=<>
method="GET"
query-format="json"
query-sort="title"
query-start=<<__start__>>
query-limit=<<__limit__>>
header-accept="application/json"
bind-status="$:/temp/zotero/status"
bind-progress="$:/temp/zotero/progress"
oncompletion=<>
onprogress=<