IBM / scc-go-sdk

GoLang SDK for IBM Cloud Security and Compliance Center
https://cloud.ibm.com/docs/security-compliance
Apache License 2.0
2 stars 9 forks source link

Not able to fetch report #131

Closed ManojDhanorkar closed 1 year ago

ManojDhanorkar commented 1 year ago

I am trying below example, but always get not found error. Any pointers are appreciated on what is wrong with this code? --------------------------------------CODE ------------------------------

package main

import ( "encoding/json" "fmt" "os"

"github.com/IBM/go-sdk-core/v5/core"
scc "github.com/IBM/scc-go-sdk/v5/securityandcompliancecenterapiv3"

)

func main() {

ibm_scc_key := os.Getenv("IBM_SCC_KEY")
securityAndComplianceCenterApiService, err := scc.NewSecurityAndComplianceCenterApiV3(&scc.SecurityAndComplianceCenterApiV3Options{
    URL: "https://us-south.compliance.cloud.ibm.com/",

    Authenticator: &core.IamAuthenticator{
        ApiKey: ibm_scc_key,
    },
})

if err != nil {
    panic(err)
} else {

    fmt.Println("Connected successfully")
}

getLatestReportsOptions := &scc.GetLatestReportsOptions{

    InstanceID: core.StringPtr("XXXXXXXX"),
}
getLatestReportsOptions.SetSort("profile_name")

reportLatest, response, err := securityAndComplianceCenterApiService.GetLatestReports(getLatestReportsOptions)
if err != nil {
    panic(err)
}
b, _ := json.MarshalIndent(reportLatest, "", "  ")
fmt.Println(string(b))
print(response)

} -------------------- RESPONSE ------------------

$ go run main.go Connected successfully panic: Not Found

goroutine 1 [running]: main.main() D:/main.go:64 +0x295 exit status 2

ManojDhanorkar commented 1 year ago

This can be closed .. After removing extra ending "/" from https://us-south.compliance.cloud.ibm.com/ worked.