title: WidgetMessage: tm-http-request Example - Zotero tags: $:/tags/Macro \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.]]"/> \end zotero-save-item \define zotero-save-items(data) <$list filter="[jsonindexes[]] :map[jsonextract,[data]]" variable="item"> <$macrocall $name="zotero-save-item" item=<>/> \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=<>/> \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() https://api.zotero.org/groups/27508/items/?format=json&sort=title \end request-url <$action-sendmessage $message="tm-http-request" url={{{ [setquerystring[start],<__start__>setquerystring[limit],<__limit__>] }}} method="GET" header-accept="application/json" bind-status="$:/temp/zotero/status" bind-progress="$:/temp/zotero/progress" oncompletion=<> onprogress=<> var-start=<<__start__>> var-limit=<<__limit__>> /> \end \define zotero-actions() <$macrocall $name="zotero-get-items" start="0" limit="5"/> \end <$button actions=<>> Call Zotero Tiddlers:
    <$list filter="[tag[$:/tags/ZoteroImport]]">
  1. <$link> <$view field="title"/>