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 https://yourdomain.sharepoint.com/_forms/default.aspx?wa=wsignin1.0 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
https://yourdomain.sharepoint.com/_api/contextinfo

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 = "https://domain.sharepoint.com/_forms/default.aspx?wa=wsignin1.0"
			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 "https://domain.sharepoint.com/_forms/default.aspx?wa=wsignin1.0": dial tcp: lookup domain.sharepoint.com on 192.168.244.17:53: 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?

https://golang.org/pkg/net/#hdr-Name_Resolution

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.