Hello! The question is probably stupid and perhaps trivial, but I just can not figure it out and ask for your help. Trying to access the API https://russia.travel/apidoc/access/ using Go. Quote:

Russia.Travel API works via the HTTP protocol, through which all requests must be sent using the POST method to the address http://api.russia.travel/ . Requests sent must contain three required parameters:

login containing user login; hash containing the user password hash; An xml containing the body of the request in XML format according to the documentation.

That's what I'm doing:

client := &http.Client{} req, err := http.NewRequest("POST", "http://api.russia.travel/", strings.NewReader(xmlbody)) req.SetBasicAuth("view", "view") resp, err := client.Do(req) if err != nil { fmt.Println("Error! %s", err) } 

And I get error 400: invalid query syntax. In the xml-body of the request, I'm sure sending it to the sandbox gives the desired result. In this connection, I think that the case in the login hash, most likely, I am not there (wrong) using them?

I would be very grateful for the help or at least a hint in which direction to move.

    1 answer 1

    Issue resolved: https://play.golang.org/p/_mCBF8LSTR

     package main import ( "fmt" "io/ioutil" "net/http" "net/url" ) func main() { xmlBody := `<?xml version="1.0" encoding="UTF-8"?><request action="get-library" type="object-type" />` form := url.Values{} form.Add("login", "view") form.Add("hash", "view") form.Add("xml", xmlBody) resp, _ := http.PostForm("http://api.russia.travel", form) defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) fmt.Println(string(body[:len(body)])) } 

    Thank you Nikita Gritsay from the group on Go.