groovy – HTTPBuilder查询参数

groovy – HTTPBuilder查询参数,第1张

概述我试图理解HTTP Builder的简化GET.我成功地使用类似于REST GET请求的简单GET请求. def client = new HTTPBuilder('http://pokeapi.co')def resp = client.get(path: '/api/v1/pokemon/1')static void main(String[] args){ def h = ne 我试图理解http Builder的简化GET.我成功地使用类似于REST GET请求的简单GET请求.

def clIEnt = new httpBuilder('http://pokeAPI.co')def resp = clIEnt.get(path: '/API/v1/pokemon/1')static voID main(String[] args){    def h = new http()    print h.resp.name}

我接下来要做的是向查询添加参数.

def clIEnt = new httpBuilder('http://svcs.sandBox.ebay.com')def resp = clIEnt.get(path: '/services/search/FindingService/v1',ContentType: TEXT,query:[                          'Security-APPname': APP_ID,'OPERATION-name':'findItemsByKeywords','SERVICE_VERSION':'1.0.0','RESPONSE-DATA-FORMAT':'JsON','callback':'_cb_findItemsByKeywords','REST-PAYLOAD': '','keywords':'iphone 3g','paginationinput.entrIEsPerPage': '3'])}

当我打印resp时,我得到:

java.io.StringReader@16d871c0

参数的代码是否正确?我的输出有什么问题?

我的查询(当我通过浏览器运行时)产生

{"findItemsByKeywordsResponse":[{"ack":["Success"],"version":["1.13.0"],"timestamp":["2014-12-02T06:26:15.869Z"],"searchResult":[{"@count":"3","item":[{"itemID":["110089183401"],"Title":["Apple iPhone 3G - 8GB - Black (Unlocked) Smartphone"],"globalID":["EBAY-US"],"primarycategory":[{"categoryID":["9355"],"categoryname":["Cell Phones & Smartphones"]}],"galleryURL":["http:\/\/thumbs2.sandBox.ebaystatic.com\/m\/mI_iSJ1zmYlIDmuolh9PnDW\/140.jpg"],"vIEwItemURL":["http:\/\/cgi.sandBox.ebay.com\/Apple-iPhone-3G-8GB-Black-Unlocked-Smartphone-\/110089183401"],"productID":[{"@type":"ReferenceID","__value__":"100014203"}],"paymentMethod":["PayPal"],"autopay":["false"],"postalCode":["95125"],"location":["San Jose,CA,USA"],"country":["US"],"shipPingInfo":[{"shipPingServiceCost":[{"@currencyID":"USD","__value__":"2.5"}],"shipPingType":["Flat"],"shipTolocations":["US"],"expeditedShipPing":["false"],"oneDayShipPingAvailable":["false"],"handlingTime":["3"]}],"sellingStatus":[{"currentPrice":[{"@currencyID":"USD","__value__":"100.0"}],"convertedCurrentPrice":[{"@currencyID":"USD","sellingState":["Active"],"timeleft":["P25DT9H19M59S"]}],"ListingInfo":[{"bestOfferEnabled":["false"],"buyItNowAvailable":["false"],"startTime":["2011-05-17T15:41:14.000Z"],"endTime":["2014-12-27T15:46:14.000Z"],"ListingType":["FixedPrice"],"gift":["false"]}],"returnsAccepted":["true"],"condition":[{"conditionID":["1000"],"conditiondisplayname":["New"]}],"isMultiVariationListing":["false"],"topRatedListing":["false"]},{"itemID":["110116107959"],"Title":["Apple iPhone 3G - 8GB - Black (AT&T) Smartphone (MB046LL\/A)"],"galleryURL":["http:\/\/thumbs4.sandBox.ebaystatic.com\/m\/mEcUS_FQToCppxHhT12xHvw\/140.jpg"],"vIEwItemURL":["http:\/\/cgi.sandBox.ebay.com\/Apple-iPhone-3G-8GB-Black-AT-T-Smartphone-MB046LL-A-\/110116107959"],"__value__":"101892398"}],"postalCode":["98102"],"location":["Seattle,WA,"__value__":"0.0"}],"shipPingType":["Free"],"handlingTime":["1"]}],"__value__":"149.99"}],"timeleft":["P26DT22H10M10S"]}],"startTime":["2013-05-08T04:31:25.000Z"],"endTime":["2014-12-29T04:36:25.000Z"],{"itemID":["110089171954"],"galleryURL":["http:\/\/thumbs3.sandBox.ebaystatic.com\/m\/m7btqoH-DYL3EWRCDJgThJg\/140.jpg"],"vIEwItemURL":["http:\/\/cgi.sandBox.ebay.com\/Apple-iPhone-3G-8GB-Black-Unlocked-Smartphone-\/110089171954"],"timeleft":["P24DT9H2M20S"]}],"startTime":["2011-05-16T15:23:35.000Z"],"endTime":["2014-12-26T15:28:35.000Z"],"topRatedListing":["false"]}]}],"paginationOutput":[{"pageNumber":["1"],"entrIEsPerPage":["3"],"totalPages":["564"],"totalEntrIEs":["1691"]}],"itemSearchURL":["http:\/\/shop.sandBox.ebay.com\/i.HTML?_nkw=iphone+3g&_ddo=1&_ipg=3&_pgn=1"]}]}
解决方法 固定它. ContentType不是TEXT. 总结

以上是内存溢出为你收集整理的groovy – HTTPBuilder查询参数全部内容,希望文章能够帮你解决groovy – HTTPBuilder查询参数所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1238126.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存