Hi @Jyoti Mallick
I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer.
The user name was the culprit here; you don't need to send the username\\$username rather it should be only $username`
package main
import (
"encoding/base64"
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
// Replace with your correct SCM Access Key
accessKey := "<Password>" // Use the publishing password from the output
// Replace with your Azure App Service SCM URL
url := fmt.Sprintf("https://<URL>.scm.azurewebsites.net/api/vfs/site/wwwroot/logs")
// Prepare Basic authentication header
// Ensure to escape the backslash correctly
username := "$<username>" // Escaped backslash in username
auth := base64.StdEncoding.EncodeToString([]byte(username + ":" + accessKey))
// Create HTTP GET request
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatalf("Error creating request: %v", err)
}
req.Header.Set("Authorization", "Basic "+auth)
// Execute the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Fatalf("Request failed: %v", err)
}
defer resp.Body.Close()
// Handle response
if resp.StatusCode != http.StatusOK {
log.Fatalf("Error: %s", resp.Status)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalf("Error reading response body: %v", err)
}
// Print log files or handle as needed
fmt.Println("Logs retrieved successfully")
fmt.Println(string(body))
}
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.