Cannot unmarshal DNS message

Trying to connect to SharePoint as explained here, I was able to get the security token and need to post it to to get the access token.

The response from this request includes couple of cookies which must
be passed as headers with all future requests. They are marked with
the ‘Set-Cookie’ header. We need the ones beginning with rtFa= and
FedAuth=. The access token cookies must be included as Cookie headers
with the POST request of

With Thunder client I was able to get these cookies.

enter image description here

But I failed to get them through my GO code, i tried as:

            token := string(n.Content) // n.Content is obtained from XML read
			const mydomain = ""
			resp2, err := http.Post(mydomain, "text/plain;charset=UTF-8", strings.NewReader(token))
			if err != nil {
				log.Fatal("error: ", err)
			defer resp2.Body.Close()

			body2, _ := ioutil.ReadAll(resp2.Body)
			fmt.Println("response Body:", string(body2))

And got the output as:

2021/07/08 22:31:01 error: Post "": dial tcp: lookup on cannot unmarshal DNS message
exit status 1

I’m not certain, but this might be a relevant issue:

Ian Gudger implies that the Go DNS resolver adheres to the RFC 1035 standard more strictly than some DNS server (and resolver) implementations do. Maybe forcing to use the cgo resolver could help?

EDIT: Looks like there are a variety of situations that can cause this. Maybe try switching DNS servers first to see if that helps?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.