Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

marshalling tasks to JSON: json: invalid number literal "null" #63

Open
Arundas666 opened this issue Oct 1, 2024 · 0 comments
Open

Comments

@Arundas666
Copy link
Contributor

Arundas666 commented Oct 1, 2024

I tried to fetch The tasks by taskID, and it is working fine, but when i'm trying to ocnvert it to json format, it is getting this error,
`
package main

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

"github.com/joho/godotenv"
"github.com/raksul/go-clickup/clickup"

)

func fetchTasks(taskId string) (clickup.Task, error) {
api_key := os.Getenv("CLICKUP_API_KEY")
client := clickup.NewClient(nil, api_key)

tasks, _, err := client.Tasks.GetTask(context.Background(), taskId, &clickup.GetTaskOptions{})
return *tasks, err

}

func main() {

err := godotenv.Load()
if err != nil {
    log.Fatalf("Error loading .env file")
}
var taskID string
fmt.Print("Enter clickup taskID: ")
fmt.Scanf("%s", &taskID)



tasks, err := fetchTasks(taskID, )

if err != nil {
    fmt.Printf("Error: %v\n", err)
    return
}

// Convert tasks to JSON format
tasksJSON, err := json.Marshal(tasks)
if err != nil {
    fmt.Printf("Error marshalling tasks to JSON: %v\n", err)
    return
}

// Print the JSON string
fmt.Println(string(tasksJSON))

}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant