Help to post response JSON

(ext) #1

urlapi =
site for check =
content type =json

Pls help, I can’t read response in structure YndexResponseModel
am i doing right?

now response always nil

func main() {

result := CheckYandex("")
if result != nil {
	fmt.Println(result.Info, result.Url)

func CheckYandex(site string) (status *YndexResponseModel) {
type (
	Threatstr struct {
		Threat string
	YndexResponseModel struct {
		Info []Threatstr
		Url  string

var (
	apiurl    string = ""
	cl               = &http.Client{Timeout: 15 * time.Second}
	strformat        = fmt.Sprintf(`{"url": "%s"}`, site)
	jsonStr          = []byte(strformat)

r, err := http.NewRequest("POST", apiurl, bytes.NewBuffer(jsonStr))
r.Header.Set("content-type", "application/json")
r.Close = true
resp, err := cl.Do(r)
defer resp.Body.Close()

err = json.NewDecoder(resp.Body).Decode(status)

return status


(Ali Koyuncu) #2

Please keep the original question as it is and reply it as you want.

(Kristoffer Berdal) #3

If you figured it out, please post the solution here :slight_smile: Maybe someone else has a similar problem and your solution can help them.