2011-03-16 22 views

cevap

8

Sen sonrası yöntemine bir Closure'u geçmek ve orada başlıkları ayarlamak gerekir.

withHttp(uri: "http://foo/bar") { 
    def bodyContent = [ 
      apiKey: "somekey", 
      identifier: identity.identity, 
      activity: ac as JSON 
     ] 
    def json = post(path: 'activity', body: bodyContent) { 
     headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4' 
    } 
    if (json.stat == 'ok') { 
     wsr.success = true 
    } 
} 

şu da çalışması gerekir:

.... 
.... 
def json = post(path: 'activity', 
       body: bodyContent, 
       headers:['User-Agent':'myagent']) 
.... 
.... 
+0

Haklısın bahis. Bunu test edip emin olacağım. Teşekkürler. – Gregg