I am attempting to call the name.com API (and am successful, except for one call... When I attempt to call their Search() method, I am getting an error.
Here is my code:
func TestExecute() string{
client := &http.Client{}
body := []byte("keyword=web")
req, newReqErr := http.NewRequest("POST", "https://api.name.com/v4/domains:search", bytes.NewBuffer(body))
check("new Request Error: ", newReqErr)
req.SetBasicAuth("username", "[TOKEN ]")
fmt.Println(req)
resp, doErr := client.Do(req)
check("client Do Error: ", doErr)
bodyText, readErr := ioutil.ReadAll(resp.Body)
check("Read error: ", readErr)
fmt.Printf("Result: %s
", bodyText)
return fmt.Sprintf("StatusCode: %d
%s", resp.StatusCode, bodyText)
}
Here is the request text:
&{POST https://api.name.com/v4/domains:search HTTP/1.1 1 1 map[Authorization:[Basic cldokleodjjAzMWNlODY2MjRlYmI5xxkxjdkfOWI4ZjNhMWQ5NmVmOGIA5YTA=]] {keyword=web} 11 [] false api.name.com map[] map[] <nil> map[] <nil> <nil>}
and here is the response:
{"message":"Invalid Argument","details":"Error occurred during parsing: Cannot decode json string."}
It appears that some empty structs (internals, not mine) are being introduced into the header. OR name.com is parsing incorrectly.
Thoughts?