Azure Golang SDK returning HTML response instead of JSON

Brennan Macaig 1 Reputation point

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 ( 
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\" \"\">\r\n<html xmlns=\"\">\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

    @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