I have written a go programme to query issues in github repository "golang:go". The http.Get() responds with status "200 OK". I then query for issues created in last 3 months and the http.Get() returns "422 Unprocessable Entity". Below is the programme
import(
"fmt"
"time"
"net/http"
"net/url"
)
func main() {
var ret error
var str string
q:=url.QueryEscape("repo:golang/go")
fmt.Println("q:", q)
urlStr := "https://api.github.com/search/issues" +"?q=" + q
fmt.Println("urlStr:", urlStr)
resp, ret:= http.Get(urlStr)
fmt.Println("ret :", ret, "resp.status :", resp.Status)
timeStr := "created:"
to := time.Now()
from := to.AddDate(0, -3, 0)
str = to.Format("2006-01-02")
timeStr = timeStr + str + ".."
fmt.Printf("time1 : %s
", timeStr)
str = from.Format("2006-01-02")
timeStr = timeStr + str
fmt.Printf("time2 : %s
", timeStr)
q=url.QueryEscape("repo:golang/go" + timeStr)
fmt.Println("q:", q)
urlStr = "https://api.github.com/search/issues" +"?q=" + q
fmt.Println("urlStr:", urlStr)
resp, ret = http.Get(urlStr)
fmt.Println("ret :", ret, "resp.status :", resp.Status)
}
I used this to form the query.
I am new to web programming and not able to understand where I went wrong in forming the second query.