gorequest icon indicating copy to clipboard operation
gorequest copied to clipboard

how to send payload via GET method in gorequest

Open kitsaravana opened this issue 6 years ago • 2 comments

In http request, payload works payload := strings.NewReader("{"query":"text"} ") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("accept", "application/json, text/plain") res, _ := http.DefaultClient.Do(req)

In gorequest, payload not working resp, _, err := gorequest.New(). Get(url). Type("json"). Send(payload). Set("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36"). Set("accept","application/json,text/plain"). End()

kitsaravana avatar Jun 29 '18 07:06 kitsaravana

Please refer to this - https://godoc.org/github.com/parnurzeal/gorequest#SuperAgent.Query

eyJhb avatar Aug 03 '18 20:08 eyJhb

here are some examples

resp, _, errs := gorequest.New().Get(QR_CODE_URL + wxLogin.Uuid).Query(`{"t": "webwx"}`).End()
	params := Uuid{
		Appid:       "wx782c26e4c19acffb",
		RedirectUri: "https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage",
		Fun:         "new",
		Lang:        "zh_CN",
		TimeStampMs: wxLogin.TimeStampMs,
	}
	resp, body, errs := gorequest.New().Get(UUID_URL).Query(params).End()

liuweiming1997 avatar Oct 05 '19 08:10 liuweiming1997