Valentin Gomez

Generation

generate functionTue, 03 Jan 2023

interact with https://apiadv.sintia.com.ar/Help/Api/POST-Ratificacion-Login

func login(username, password string) (Token, error) { res, err := http.Post("https://apiadv.sintia.com.ar/api/Login", "application/json", strings.NewReader(fmt.Sprintf(`{"username": "%s", "password": "%s"}`, username, password)), ) if err != nil { return "", err } defer res.Body.Close() if res.StatusCode != 200 { return "", errors.New("invalid username/password") } var t Token dec := json.NewDecoder(res.Body) if err := dec.Decode(&t); err != nil { return "", err } return t, nil }

Questions about programming?Chat with your personal AI assistant