cloudfoundry/go-cfclient

calls are all getting "....invalid character '<' looking for beginning of value"

metskem opened this issue · 3 comments

While exploring the v3 version of the api (v3.0.0-alpha.4), I only got responses like :

error getting /v3/apps/7e7284b3-366f-4da9-8bdc-0cb64ee42a56: error executing request, failed during HTTP request send: Get "https://api.sys.cfd05.rabobank.nl/v3/apps/7e7284b3-366f-4da9-8bdc-0cb64ee42a56": invalid character '<' looking for beginning of value

Here is the most simple example piece of code that demonstrates the issue:

package main

import (
	"context"
	"github.com/cloudfoundry-community/go-cfclient/v3/client"
	"github.com/cloudfoundry-community/go-cfclient/v3/config"
	"log"
	"os"
)

var (
	apiAddress   = "https://api.sys.mydomain.com"
	clientId     = "testClientID"
	clientSecret = "testClientSecret"
)

func main() {
	appGuid := os.Args[1]
	if cfConfig, err := config.NewClientSecret(apiAddress, clientId, clientSecret); err != nil {
		log.Fatalf("failed to create new config: %s", err)
	} else {
		if cfClient, err := client.New(cfConfig); err != nil {
			log.Fatalf("failed to create new client: %s", err)
		} else {
			if cfApp, err := cfClient.Applications.Get(context.Background(), appGuid); err != nil {
				log.Fatalf("failed to get app with guid %s: %s", appGuid, err)
			} else {
				log.Printf("got apps %v", cfApp)
			}

		}
	}
}

Some further debugging shows that a response is in html format while (I think) json format was expected, it looks like a request header like Accept: application/json is missing somewhere. Probably the request to login.sys.mydomain.com

We see the same result for cfClient.Applications.ListAll().

Am I missing something here, or is this a bug?

Same error with cfClient.ServiceOfferings.ListAll()

sneal commented

Fixed

thanks!