は、ID 16854ある特定のプロジェクトのための1つのショーアップのidの1話を作るのコードサンプルです:
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.GET
import static groovyx.net.http.ContentType.JSON
public class StoryGetter {
public static void main(String[] args) {
new StoryGetter().getStories()
}
void getStories() {
// http://agilezen.com/project/16854/story/4
// /api/v1/project/16854/story/2
def http = new HTTPBuilder('http://agilezen.com')
http.request(GET, JSON) {
uri.path = '/api/v1/project/16854/story/1'
headers.'X-Zen-ApiKey' = 'PUT YOUR OWN API KEY HERE'
response.success = { resp, json ->
println "json size is " + json.size()
println json.toString()
}
}
}
}
私は必要があるため、この記事では、偽のAPIキーに入れていました私のAPIキーを共有しないでください。
(ちなみに、これはSSLを使用していないSSL対応のプロジェクトのためにこれをやっに関してでフォローアップの質問はすぐに来るかもしれない。。)
役立つヒントを:uri.path =「/ API/V1/project/$ {PROJECT_ID}/stories "とjson.totalItemsはあなたにストーリーの総数を返します。 jsonの名前をストーリーに変更すると、やりやすくなります。 – finneycanhelp