Azure Golang SDK returning HTML response instead of JSON

Brennan Macaig 1 Reputation point
2020-07-07T15:17:39.377+00:00

I have some code written in Go using the Azure SDK for Go. I'm trying to get a DNS TXT record from a known zone. I have the following in Go:

import ( 
    "github.com/Azure/go-autorest/autorest/azure/auth"
    "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns"
    "log"
)
cli := dns.NewRecordSetsClient("subscription-id-goes-here")
authorizer, err := auth.NewAuthorizerFromEnvironment()
// Error checking and stuff the authorizer into cli
// ....
valu, err := cli.Get(context.Background(), "resource-group", "zone", "", dns.RecordType("TXT"))
if err != nil {
    log.Fatalf("Error: %s", err.Error())
}

The output of that error looks something like this:

dns.RecordSetsClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: error response cannot be parsed: "\ufeff<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n <head>\r\n <title>Service</title>\r\n <style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } " error: invalid character 'ï' looking for beginning of value

What am I doing wrong with my request, and why am I getting what is obviously HTML back?

Azure DNS
Azure DNS
An Azure service that enables hosting Domain Name System (DNS) domains in Azure.
632 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sumarigo-MSFT 45,401 Reputation points Microsoft Employee
    2020-07-21T15:00:41.307+00:00

    @BrennanMacaig-4299 Firstly, apologies for the delay in responding here and any inconvenience this issue may have caused.

    Based on the error code 404 the URL is not accessible(missing) I also see you have posted similar question in SO forum, have you referred to the suggestion mentioned over-there. If issue still persist, please share the screenshot of the error message.

    Hope this helps!

    Kindly let us know if the above helps or you need further assistance on this issue.


    Please do not forget to "Accept the answer" and Upvote on the post that helps you, this can be beneficial to other community members.

    0 comments No comments